function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GMMGMM 

Field History - User Friendly Data

I use the following snippet of code to display a field history for a custom object:

 

    <apex:pageBlock title="Field History">
        <apex:pageBlockTable value="{!Custom_Object__c.Histories}" var="History">
            <apex:column headerValue="Date"><apex:outputText value="{!History.CreatedDate}" /></apex:column>
            <apex:column headerValue="Field"><apex:outputText value="{!History.Field}" /></apex:column>
            <apex:column headerValue="New Value"><apex:outputText value="{!History.NewValue}" /></apex:column>
            <apex:column headerValue="Old Value"><apex:outputText value="{!History.OldValue}" /></apex:column>
<apex:column headerValue="Modified By"><apex:outputText value="{!History.CreatedById}" /></apex:column> </apex:pageBlockTable> </apex:pageBlock>

 It works just fine, but for the Field name it displays in the format: Custom_Field_Name__c and for Modified By it displays the person's SFDC ID.

 

Are either of the following possible:

1. Instead of the field's API Name, return the singular or plural label?

2. Instead of the person's SFDC ID, return the person's name?

 

Thanks! 

Pradeep_NavatarPradeep_Navatar

If there is a relationship(lookup) between objects then you can get all fields through lookup relationship. For an example : Account and contact object are linked with each other with lookup relationship. In this case we can fetch account name by using contact.Account.name. We can access fields of lookup object upto two levels.

 

Hope this helps.