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
Mohan sharmaMohan sharma 

How to use related list for custom and standard object.?

Hi All,
           I want to make a visualforce page and i want to override standard functionality like show related list in visualforce page so how can i achive it ?. And then i want to show this related list in visualforce page similer to standard object related list.
Best Answer chosen by Mohan sharma
Deepak Kumar ShyoranDeepak Kumar Shyoran
You can get related list by using apex:relatedList tag and with the help of ChildRelationship Name to fetch Related list see below example.

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


All Answers

Deepak Kumar ShyoranDeepak Kumar Shyoran
You can get related list by using apex:relatedList tag and with the help of ChildRelationship Name to fetch Related list see below example.

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


This was selected as the best answer
Jagannatha Reddy BandaruJagannatha Reddy Bandaru
Hi Mohan,

you can get related list by using following steps

<apex:page standardcontroller="Account">
             <apex:detail relatedList="true">
</apex:page> 


you can add this page to view in the buttons or links of particular object(Account)


if you want to display selected related list then you can do like this

<apex:page standardcontroller="Account">
       <apex:detail relatedList="false">
       <apex:relatedList List="Contacts">
       <apex:relatedList List="AccountContactRoles"/>
       <apex:relatedList list="ActivityHistories"/>
       <apex:relatedList list="CombinedAttachments"/>
</apex:page>

Thanks,
Jagan