1

Can any one help how to add Contact History Related List in VF pages? I have added for Created date ,Field ,From and To. But I am not able to add the user who is changing the data. Here is the VF pages which i have written.

<apex:pageBlock id="thePageBlock" title="ContactHistory">  
<apex:pageBlockTable value="{!contact.Histories}" var="c">
         <apex:column headerValue="Date" value="{!c.createddate}"/>

          <apex:column headerValue="What" value="{!c.field}"/>
         <apex:column headerValue="From" value="{!c.oldvalue}"/>
          <apex:column headerValue="To"  value="{!c.newvalue}"/>
     </apex:pageBlockTable>
</apex:pageBlock>

Here i would like to add User as well. Could any one help?

8
  • Did you try using LastModifiedBy like <apex:column headerValue="Last Modified By" value="{!c.LastModifiedBy}"/> Jan 2, 2015 at 5:36
  • I tried but iam getting this error.Invalid field LastModifiedBy for SObject ContactHistory
    – sravya
    Jan 2, 2015 at 5:49
  • This is how i have written. <apex:pageBlock id="thePageBlock" title="ContactHistory"> <apex:pageBlockTable value="{!contact.Histories}" var="c"> <apex:column headerValue="Date" value="{!c.createddate}"/> <apex:column headerValue="Last Modified By" value="{!c.LastModifiedById}"/> <apex:column headerValue="What" value="{!c.field}"/> <apex:column headerValue="From" value="{!c.oldvalue}"/> <apex:column headerValue="To" value="{!c.newvalue}"/> </apex:pageBlockTable> </apex:pageBlock>
    – sravya
    Jan 2, 2015 at 5:51
  • Opps... I missed this bit you are asking for Object history right.... Sorry we can't track Created By and Last Modified By.. Help link help.salesforce.com/… Jan 2, 2015 at 5:51
  • cant we track User as well?
    – sravya
    Jan 2, 2015 at 5:53

2 Answers 2

1

You can use CreatedbyId to track the user of the history record. I am not sure why this is not in the salesforce online document though. Source: Link

1
  • This should be the answer.
    – rmarq423
    Oct 20, 2016 at 18:28
0

For Contact History, you can only display these fields in the VF page.

  1. Field
  2. IsDeleted
  3. ContactId
  4. OldValue
  5. NewValue

From tracking standpoint, you cannot track :

  1. Formula, roll-up summary, or auto-number fields
  2. Created By and Last Modified By

Owner field can always be tracked, if that solves your purpose.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .