+ Start a Discussion
TechSteveTechSteve 

Standard field 'CreatedBy' shows wrong in a visualforce page!

When you drag the standard field into a standard layout of the contact object it displays the name of the user who created the record and the date & time of creation.

 

When I used it in a vf page all it shows is 005200000025bX9AAI?

 

Tried <apex:outputlabel value="{!contact.CreatedBy}"/>, <apex:outputText >{!contact.CreatedBy}</apex:outputText> as two ways to display it with the same results.

 

Any idea's whats wrong and how I get it to do the  same as it would in a normal layout.

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Sweta AgnihotriSweta Agnihotri
Hi,
Please use <apex:outputField> instead of using <apex:outputText>.
Here is the code which performs the functionality you want:



<apex:page standardController="Contact">
    <apex:outputField value="{!contact.Name}"/>
    <p/>
    <apex:outputField value="{!contact.CreatedById}"/> &nbsp;
    <apex:outputField value="{!contact.CreatedDate}"/>
</apex:page>

 I hope this helps

 

Thanks

All Answers

jwetzlerjwetzler

Use outputField instead of outputText (just FYI if you were going to use outputText you should put {!contact.CreatedBy} in the value attribute, but that still wouldn't fix your problem as outputText just shows you the value stored in the database).

Sweta AgnihotriSweta Agnihotri
Hi,
Please use <apex:outputField> instead of using <apex:outputText>.
Here is the code which performs the functionality you want:



<apex:page standardController="Contact">
    <apex:outputField value="{!contact.Name}"/>
    <p/>
    <apex:outputField value="{!contact.CreatedById}"/> &nbsp;
    <apex:outputField value="{!contact.CreatedDate}"/>
</apex:page>

 I hope this helps

 

Thanks

This was selected as the best answer