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
Devendra@SFDCDevendra@SFDC 

Display Child-Parent Records

Hello Board,

 

How to loop through child objects, find the parent records?

 

Child 1
Parent 1
Child 2
Parent

 

Summary by Child object

 

Thanks,

Devendra

Navatar_DbSupNavatar_DbSup

Hi,

 

You have to simply make the SOQL to get the parent record like below:

 

List<string> parentObjectName=new list<string>();

For(childObject__c  chld :[select id,name ,parentObject__c from childObject__c])

{

parentObjectName.add(chld. parentObject__c);

}

System.debug(‘@@@@@@@@@@@@@@@@@@@’ + parentObjectName);// will display all the parent records name

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

Devendra@SFDCDevendra@SFDC

Thanks Navtar,

 

I want to display these parent records on VF page in following manner.

 

Child 1
        Parent 1
Child 2
        Parent 2

 

How to display these records on VF page?

 

Thanks,

Devendra