5

I have a custom Visualforce page at the end of which I want to display some related object list (like Activity Histories, Notes and Attachments) as they are on the standard detail page of a record.

What should I use in a <apex:relatedList> tag to display Custom Object History related list?

For example: Assume the custom object name as Detail_Rec__c.

So I tried this:

<apex:relatedList list="Detail_Rec__Histories" />

and got "invalid child relationship name" error.

5

For notes and attachment use following name in tag:-

<apex:relatedList subject="{!account}" list="NotesAndAttachments" />

For Activity History:

<apex:relatedList subject="{!customObject__c}" list="ActivityHistories" />

For native object History Ex: Opportunity:

 <apex:relatedlist list="OpportunityHistories" title="Opp History"/>
  • Sorry for not mentioning this in my question earlier, I'm actually searching for History related list of a custom object. See my updated question. – Simran Sep 23 '14 at 19:20
  • 2
    regal - note that OpportunityHistories is the stage history, not the field history. – cropredy Sep 24 '14 at 3:38
1

Unfortunately, you cannot display the field history of a standard or custom object using the Related List tag. Apart from Jquery method shown by Aidan, you can also create a custom component to display the history related list.

There is a very good discussion on this with component code as well on the following link: https://developer.salesforce.com/forums?id=906F000000095wwIAA

Hope it helps.

0

Old question, I know, but I came here through Google. There is an alternative to custom components... (as long as you don't mind jQuery)

You can use <apex:detail> to get SF magic to put the related lists in, then use jQuery to remove all the bits you don't need. Not efficient in terms of page-loading, but works nicely to get hold of components that are not otherwise exposed in Visualforce.

Obviously, bring jquery in as a static resource:

<apex:includeScript value="{!URLFOR($Resource.jquery)}"/>

At the bottom of your page have:

<div id="objDetailForRelatedLists">
  <apex:detail relatedList="true" subject="{!myObj.id}" relatedListHover="false" inlineEdit="false" showChatter="false"  />
</div>

Then, somewhere else in the page:

<script>
$(document).ready(function() {
    $('#objDetailForRelatedLists').children().not('.bRelatedList').remove();
});
</script>
  • Aidan, I implemented this and it does work, but it brings the entire record with all related lists. Is there a way to remove the record details and just leave the related lists? – MicroSumol Jul 16 '15 at 16:30
  • The jQuery is supposed to remove the details of the record... Make sure you have put in jQuery as a static resource and included the <script>...</script> part, above – Aidan Jul 17 '15 at 7:16

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.