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
ravi teja 81ravi teja 81 

showing related list fields when i click on a particular id

User-added image
hi i have two sobjects(agreement,rules) rules is the child object of agreement when i click on the link the related list should be displayed on output panel . how can i do it? 
NagaNaga (Salesforce Developers) 
Hi Ravi,


Create a page that uses the standard controller for "A".  Create a controller extension that gets the "A" record from the standard controller, and queries for the most recent "B" record.  Something like this:

B bRecord = [SELECT Id, other fields FROM B ORDER BY CreatedDate DESC LIMIT 1];

Then you can get all the "C" records related to the "B" record:

List<C> cRecords = [SELECT Id, other fields FROM C WHERE B_Lookup__c = :bRecord.Id];

In the VF page, display the details for the "A" and "B" records, then use a "pageBlockTable" (or maybe a "repeat") to show all the "C" records:

<apex:pageBlockTable value="{!cRecords}" var="crecord" >
    <apex:outputField value="{!crecord.A_Field__c}"/>
    and so on...
</apex:pageBlockTable>

Please follow the below link for more info

https://developer.salesforce.com/forums/ForumsMain?id=906F00000009DxDIAU

Best Regards
NagaKiran