You need to sign in to do that
Don't have an account?

Showing Owner field value on visualforce page
Hi All,
I have created visual force page and I want to show owner field of the object on this page for which I created this page.
I tried different ways mentioned below but it did not work. I am able launch the page but owner field remains blank where as other fields works fine.
Other fields are custom fields and owner field is standard field
My code is like this -
Visualforce page :
( Not complete code just important one)
<apex:outputField label="Owner" value="{!Shipments__c.Owner}"/> // with controller name
<apex:outputField label="Owner" value="{!Shipments__c.Ownerid}"/> // with controller name
<apex:outputField label="Owner" value="{!Shipments.Owner}"/> // using object name
<apex:outputField label="Owner" value="{!Shipments.Ownerid}"/> // using object name
and My controller class is :
Is this because I am creating new object and new object contains all null values initially ?
How I can get owner name on my vusalforce page ?
When I use standard layout for creating new object provided by salesforce without using visualforce page, I do see owner field gets populated properly.
Please help.
Thanks,
Abhishek
I have created visual force page and I want to show owner field of the object on this page for which I created this page.
I tried different ways mentioned below but it did not work. I am able launch the page but owner field remains blank where as other fields works fine.
Other fields are custom fields and owner field is standard field
My code is like this -
Visualforce page :
( Not complete code just important one)
<apex:page standardController="Shipments__c" extensions="shipment"> <apex:inputField value="{!shipment.Related_Opportunity__c}"/> <apex:inputField value="{!shipment.Basis_Technical_Contact__c}"/> <apex:outputField label="Owner" value="{!Shipments__c.Owner.name}"/>I also tried replacing value of fields to :
<apex:outputField label="Owner" value="{!Shipments__c.Owner}"/> // with controller name
<apex:outputField label="Owner" value="{!Shipments__c.Ownerid}"/> // with controller name
<apex:outputField label="Owner" value="{!Shipments.Owner}"/> // using object name
<apex:outputField label="Owner" value="{!Shipments.Ownerid}"/> // using object name
and My controller class is :
public class shipment { public Shipments__c shipment{get;set;} public shipment(ApexPages.StandardController controller) { shipment = new Shipments__c(); } }
Is this because I am creating new object and new object contains all null values initially ?
How I can get owner name on my vusalforce page ?
When I use standard layout for creating new object provided by salesforce without using visualforce page, I do see owner field gets populated properly.
Please help.
Thanks,
Abhishek
All Answers
Yes you are right because shipment is used for creating new record so initially it contains null values.
so if you want to show Owner name then use $User or $UserInfo.
i.e
{!$User.FirstName} same as Last name {!$User.LastName}
Or in Controller you can use :
And access u in Vf page
Let me know it helped or not.
Regards
Virendra
Its working great. :-)
May I know when I save this object, How I can assign this value to the owner field.
Because owner field is not a field of type string. It requires object of type Lookup(User,Queue)
How to get the value of user which I can store in owner field.
Thanks,
Abhishek