+ Start a Discussion
Aaqib FarooqAaqib Farooq 

How do I display a custom related list in a Visualforce page?

Here's the scenario:
I created a custom object and added some fields to it and put this custom object into the Account layout. So now the Accounts page has a custom related list on it.
I want to display this custom related list on a visualforce page using <apex:relatedList list="###how do i reference the custom related list###"/>
I am using the Account standardController. My question is: how do i reference this custom related list so that I can display it on my visualforce page?
Thanks.
SonamSonam (Salesforce Developers) 
The related list you have on your Account object must be an object which is linked to the Account with a relationship/lookup or masterdetail:

use the following example :

<apex:page standardController="MyMasterObject__c">
<apex:relatedList list="MyChildObjects__r" />
</apex:page>

reference:
https://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_custom_mapping.htm:


shiv@SFDCshiv@SFDC
<apex:page standardController="MyLookupObject__c">
	<apex:relatedList list="MyChildObjects__r" />
</apex:page>
I hope custom VF page which you have built is having a standard controller. Put your custom object name on the place of MyLookupObject__c and relationship on the place of MyChildObjects__r .

If this resolove your issue please marks answer as solution.
Thanks !
visitorvivvisitorviv
Hi,

I want to completely customize the related list which contains specific logics of filtering . I have created a related list using vf page but the New button and the Actions links are not implemented. Can anyone give idea for this.

This is like contact related list in account std page. In this related list , I want to have a new Contact button which navigates to the creation of the New contact record page. and on cancel should navigate back to this std account page layout.

Similarly need to have editand delete action links like std related list.

can anyone pls help