+ 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