1

I am using standard controller of a custom object called Enagements__c to display details of the record in VF Page. I want to use the standard feature of '<apex:relatedlist' and display all the related list for that object.

I am not able to display the history tracking section and giving a strange error, even though i give the child relationship name correctly it still gives me a error.

<apex:relatedList list="Engagements__history"/>

Error i get when see the output is :

'Engagements__history' is not a valid child relationship name for entity Engagements

I am confused since when query the history tracking from SOQL it works fine which shows that relationship name is correct

SELECT Id, customfield__c, (SELECT OldValue, NewValue FROM Enagements__history) FROM Engagements__c

How do we get the history tracking relatedlist of a customobject to use

<apex:relatedList list="Engagements__history"/>
2
  • 1
    Are you sure that SOQL query works? I would expect the relationship name to be Engagements__Histories. Commented Mar 30, 2016 at 3:01
  • use describe call and check correct relationship name Schema.DescribeFieldResult f = Schema.sObjectType.Order_Line_Item__c.fields.Order__c; System.debug(f.getRelationshipName()); check this post salesforce.stackexchange.com/questions/23498/…
    – Ratan Paul
    Commented Mar 30, 2016 at 3:08

2 Answers 2

1

This is not possible out of the box. Here you can find a custom component created by John De Santiago - one of the most advanced "native looking" History list recreations.

1
  • recommended; has one issue in that it is hard to test without seeAllData=true as you can't mock history records
    – cropredy
    Commented Mar 30, 2016 at 17:17
0

I ran into similar issue when I tried using History relatedList with a standard controller. I ended up implementing as follows.Let me know if this helps.

..
..
<apex:pageBlockTable value="{!myCustomObject__c.Histories}" var="hist">
<apex:column headerValue="Date" value="{!hist.createddate}"/>
<apex:column headerValue="User" value="{!hist.createdbyid}"/> 
..
..

You must log in to answer this question.

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