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
Sfdcsupport.ax1869Sfdcsupport.ax1869 

Question regarding the Visualforce showing related list

 

How Can I get the API name (to call the related list) of the Object History?

 

Example:


I created a "Test" custom object and I enabled the "Track Field History" which in return will have a related list of "Test History" related list.

 

In my vf page, I set this code:

 

<apex:detail relatedList="false"/> <!-- Will disabled all Related Lists -->

 

How can I show the "Test History" related list only, I was not able to get the API name of this Related list.

 

 <apex:relatedList list="Question: What should be the API Name for Test History?"/>

 

 

Is it possible to call the API Name of the Test History? If so, how can I get the API name?

 

 

My current workaround is as follows:

<apex:detail relatedList="true"/>

 

In page layout remove all the related list except for Test History related list.

Best Answer chosen by Admin (Salesforce Developers) 
Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

Related list API name for the History details of an obejct is 'Histories'.

You cannot directly say as <apex:relatedList list="<objectname>.<API name>"/> for retriving the history details.

 

Here your object name is Test right?. So, you need to include the following code in  your VF page,

 

<apex:form >
        <apex:pageBlock id="thePageBlock"  title="Test Histories"  >            
            <apex:pageBlockTable value="{!Test__c.Histories}" var="h">
                <apex:column headerValue="Date"  value="{!h.createddate}"/>              
                  <apex:column headerValue="User" value="{!h.CreatedById}"/>
                  <apex:column headerValue="Action" value="{!h.Field}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>

 

 

Hope this will help you...!

 

Please don't forget to give kudos and mark this as a solution, if this works out.

All Answers

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

Related list API name for the History details of an obejct is 'Histories'.

You cannot directly say as <apex:relatedList list="<objectname>.<API name>"/> for retriving the history details.

 

Here your object name is Test right?. So, you need to include the following code in  your VF page,

 

<apex:form >
        <apex:pageBlock id="thePageBlock"  title="Test Histories"  >            
            <apex:pageBlockTable value="{!Test__c.Histories}" var="h">
                <apex:column headerValue="Date"  value="{!h.createddate}"/>              
                  <apex:column headerValue="User" value="{!h.CreatedById}"/>
                  <apex:column headerValue="Action" value="{!h.Field}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>

 

 

Hope this will help you...!

 

Please don't forget to give kudos and mark this as a solution, if this works out.

This was selected as the best answer
Sfdcsupport.ax1869Sfdcsupport.ax1869
Thanks.

The solution you gave works like a charm!
Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan
Thank you..!