2

I have a custom object called service_request__c It has field history tracking enabled and is displayed with a custom visual force page. I have other related list that work just fine using something like

<apex:relatedList list="CombinedAttachments" id="notes2" subject="{!$CurrentPage.parameters.id}"/>

However I've tried many things and cannot get the Field tracking history to show with a related list. How do I accomplish reference the field history for my custom object

2 Answers 2

3

You use the Histories object. Here's a demo page:

<apex:page standardController="service_request__c">
    <apex:relatedList list="Histories"/>
</apex:page>

There's no need to specify a subject if you use the standard controller.

1
  • Thanks sfdcfox. I also had to bring the api version of the page up like @battery.cord says below before it worked. I tried to change api version to v44 as he said through eclipse but the actual version in the SF org didn't change. I did it directly through salesforce interface and highest available to me was v43 and that worked. Thanks to both of you for the help
    – Ohmicron
    Commented Sep 28, 2018 at 18:17
3

Spent a bit futzing about with workbench & the related list component, trying names before I googled it and found an old SO question:

How to display History related list using <apex:relatedList> or by any other direct approach on a Visualforce page?

TL;DR: You can't. Make your own component to display the history.


@sfdxfox's answer says you can, but I couldn't repo it on cs67, until I updated the API version of the page I was using from v30 to v44. Make sure you're using the newest API version of your page if you still have issues. Leaving this here for anyone else who has the same issue.

5
  • That's exactly what I did with one of the custom objects on my org, and I get "'Histories' is not a valid child relationship name for entity CustomObject" when I try to load the page with an id w/ valid history records under the table. Commented Sep 28, 2018 at 17:50
  • History Tracking is enabled, and I can access the records history via the Custom_Object__History table. My page looks exactly like yours, a standardController and a single relatedList node. But loading the page provides the error. Commented Sep 28, 2018 at 17:54
  • Found it - API version problem. The page I was using was set to version 30! Moving that up to v44 fixes the problem. Commented Sep 28, 2018 at 17:56
  • 1
    Looks like we cross comments. Anyways, yeah, version issue sounds about right.
    – sfdcfox
    Commented Sep 28, 2018 at 18:01
  • 1
    Eclipse looked like it change my version but apparently v44 wasn't available in my Sandbox so I went directly into salesforce and changed the version to the highest available (v43 for me) and then it worked
    – Ohmicron
    Commented Sep 28, 2018 at 18:21

You must log in to answer this question.

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