{"id":2223,"date":"2010-04-15T23:56:09","date_gmt":"2010-04-15T18:56:09","guid":{"rendered":"http:\/\/www.chiragmehta.info\/chirag\/?p=2223"},"modified":"2010-04-16T00:02:02","modified_gmt":"2010-04-15T19:02:02","slug":"visualforce-adding-history-related-list-to-tabbed-account","status":"publish","type":"post","link":"https:\/\/www.chiragmehta.info\/chirag\/2010\/04\/15\/visualforce-adding-history-related-list-to-tabbed-account\/","title":{"rendered":"Visualforce &#8211; Adding History related list to Tabbed Account"},"content":{"rendered":"<p><strong>Problem Statement<\/strong><br \/>\nHas anyone been able to generate the &#8220;account history&#8221; tab in visualforce page? If i try using &#8220;Histories&#8221; in &lt;apex:relatedList&gt;, I get error msg saying it is not valid child relation name..<\/p>\n<p><strong>Solution1<\/strong><br \/>\nThis works for me to add a link to the account field history:<\/p>\n<blockquote><p>\n&lt;apex:tab label=&#8221;Field History&#8221; name=&#8221;Field History&#8221; id=&#8221;fieldhistory&#8221;&gt;<br \/>\n&lt;apex:outputLink value=&#8221;https:\/\/na1.salesforce.com\/_ui\/common\/history\/ui\/EntityHistoryFilterPage?id={!account.id}&#8221;&gt;<br \/>\nclick to view field history<br \/>\n&lt;\/apex:outputLink&gt;<br \/>\n&lt;\/apex:tab&gt;<\/p><\/blockquote>\n<p>Not optimum as user has to click the link but you dont need to do a lot of work.<\/p>\n<p><strong>Solution2<\/strong><br \/>\nI also figured out how to access the Account History data.  It is NOT a related list.  Instead, use the code &lt;apex:dataTable&gt; to pull from the account.histories table.  Below is rough code that will pull the Account History into a separate tab.  The HTML formating is not very clean, but the data query works!:<\/p>\n<blockquote><p>\n&lt;apex:tab label=&#8221;Field History&#8221; name=&#8221;Account History&#8221; id=&#8221;fieldhistory&#8221; &gt;<br \/>\n&lt;apex:dataTable value=&#8221;{!account.histories}&#8221; var=&#8221;accounthistory&#8221; id=&#8221;HistTable&#8221; rowClasses=&#8221;odd,even&#8221;<br \/>\nstyleClass=&#8221;tableClass&#8221; cellspacing=&#8221;15&#8243; width=&#8221;80%&#8221;&gt;<br \/>\n&lt;apex:facet name=&#8221;caption&#8221;&gt;&lt;\/apex:facet&gt;<br \/>\n&lt;apex:facet name=&#8221;header&#8221;&gt;Field History&lt;\/apex:facet&gt;<br \/>\n&lt;apex:facet name=&#8221;footer&#8221;&gt;&lt;\/apex:facet&gt;<br \/>\n&lt;apex:column&gt;<br \/>\n&lt;apex:facet name=&#8221;header&#8221;&gt;Edit Date&lt;\/apex:facet&gt;<br \/>\n&lt;apex:facet name=&#8221;footer&#8221;&gt;&lt;\/apex:facet&gt;<br \/>\n&lt;apex:outputText value=&#8221;{0,date,MM\/dd\/yyyy HH:mm }&#8221;&gt;<br \/>\n&lt;apex:param value=&#8221;{!accounthistory.createddate}&#8221; \/&gt;<br \/>\n&lt;\/apex:outputText&gt;<br \/>\n&lt;\/apex:column&gt;<br \/>\n&lt;apex:column&gt;<br \/>\n&lt;apex:facet name=&#8221;header&#8221;&gt;Field&lt;\/apex:facet&gt;<br \/>\n&lt;apex:facet name=&#8221;footer&#8221;&gt;&lt;\/apex:facet&gt;<br \/>\n&lt;b&gt; &lt;apex:outputText value=&#8221;{!accounthistory.field}&#8221;\/&gt;&lt;\/b&gt;<br \/>\n&lt;\/apex:column&gt;<br \/>\n&lt;apex:column&gt;<br \/>\n&lt;apex:facet name=&#8221;header&#8221;&gt;Edited By&lt;\/apex:facet&gt;<br \/>\n&lt;apex:facet name=&#8221;footer&#8221;&gt;&lt;\/apex:facet&gt;<br \/>\n&lt;apex:outputText value=&#8221;{!accounthistory.createdby.name}&#8221;\/&gt;<br \/>\n&lt;\/apex:column&gt;<br \/>\n&lt;apex:column&gt;<br \/>\n&lt;apex:facet name=&#8221;header&#8221;&gt;Old Value&lt;\/apex:facet&gt;<br \/>\n&lt;apex:facet name=&#8221;footer&#8221;&gt;&lt;\/apex:facet&gt;<br \/>\n&lt;apex:outputText value=&#8221;{!accounthistory.oldvalue}&#8221;\/&gt;<br \/>\n&lt;\/apex:column&gt;<br \/>\n&lt;apex:column&gt;<br \/>\n&lt;apex:facet name=&#8221;header&#8221;&gt;New Value&lt;\/apex:facet&gt;<br \/>\n&lt;apex:facet name=&#8221;footer&#8221;&gt;&lt;\/apex:facet&gt;<br \/>\n&lt;apex:outputText value=&#8221;{!accounthistory.newvalue}&#8221;\/&gt;<br \/>\n&lt;\/apex:column&gt;<br \/>\n&lt;\/apex:dataTable&gt;<br \/>\n&lt;\/apex:tab&gt;<\/p><\/blockquote>\n<p>Source : Salesforce Community<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Statement Has anyone been able to generate the &#8220;account history&#8221; tab in visualforce page? If i try using &#8220;Histories&#8221; in &lt;apex:relatedList&gt;, I get error msg saying it is not valid child relation name.. Solution1 This works for me to add a link to the account field history: &lt;apex:tab label=&#8221;Field History&#8221; name=&#8221;Field History&#8221; id=&#8221;fieldhistory&#8221;&gt; &lt;apex:outputLink [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[169],"class_list":["post-2223","post","type-post","status-publish","format-standard","hentry","category-salesforce","tag-salesforce","post-preview"],"_links":{"self":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/2223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/comments?post=2223"}],"version-history":[{"count":6,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/2223\/revisions"}],"predecessor-version":[{"id":2225,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/2223\/revisions\/2225"}],"wp:attachment":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/media?parent=2223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/categories?post=2223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/tags?post=2223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}