I have a requirement to show history value, Newvalue and Oldvalue in pagelayout for a custom object.

SELECT Field,NewValue,OldValue FROM Requirements__History

enter image description here

Is it possible to achieve this without custom coding?


You can use apex:relatedlist to achieve this. Please have a look at below link,


  • It might help to include a more complete code sample. What would be the list name, for instance?
    – Adrian Larson
    May 27 '15 at 18:52
  • @victor The question says without custom coding, How would you use <apex:relaetdlist> without using a VF page?
    – Rao
    May 27 '15 at 19:06
  • That is true. Missed that point. Thanks Rao. @Tamil - If you are trying to use standard page layout, you can just enable "History Tracking" at object level and edit page layout. Then insert related History related list to page layout.
    – Victor
    May 27 '15 at 19:09

I have made this to work.Got one problem I am not able to view the history value for Long Text area.

VF Page:

<apex:page standardController="TestHistoryTrack__c" extensions="dispHistLog"  >
<apex:form >    
   <div style="overflow: scroll; width: 100%; height: 200px;">       
    <apex:pageBlock >
        <apex:pageBlockTable value="{!lstObj}" var="a">
            <apex:column headerValue="Created Date" value="{!a.CreatedDate}"/> 
            <apex:column headerValue="User" value="{!a.CreatedBy.Name}"/>
            <apex:column headerValue="Field Name" value="{!a.Field}" /> 
            <apex:column headerValue="Old Value" value="{!a.OldValue}"/>
            <apex:column headerValue="New Value" value="{!a.NewValue}"/>

APEX Class:

public class dispHistLog
    public List<objectHistoryLine> wrapperList {get;set;}
    public Id idval;

    public dispHistLog(ApexPages.StandardController stdController)
        wrapperList = new List<objectHistoryLine>();
        idval = ApexPages.currentPage().getParameters().get('id');
        List<TestHistoryTrack__History> lstObj = [SELECT CreatedBy.Name,CreatedById,CreatedDate,Field,IsDeleted,OldValue,NewValue
                                                    FROM TestHistoryTrack__History 
                                                   WHERE ParentId =: + idval
                                                    ORDER BY CreatedDate DESC

        for(TestHistoryTrack__History h : lstObj)
            if(h.OldValue !=null)
                objectHistoryLine objH = new objectHistoryLine();
                objH.hField = h.Field;
                objH.hOldValue = String.valueOf(h.OldValue);
                objH.createdByName = String.valueOf(h.CreatedBy.Name);
                objH.dataCreated = String.valueOf(h.CreatedDate);
                objH.hNewValue = String.valueOf(h.NewValue);

    public class objectHistoryLine {
        public String hField {get; set;}
        public String hOldValue {get; set;}
        public string createdByName {get;set;}
        public string dataCreated {get;set;}
        public string hNewValue {get;set;}
  • Changes to fields with more than 255 characters are tracked as edited, and their old and new values are not recorded. Reference help.salesforce.com/… Jun 24 '15 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.