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
Suresh(Suri)Suresh(Suri) 

Is there any other way to retrieve grandparent id using grand child object

Hi All,

Is there any other way to retrieve grandparent id using grand child object in apex. Here am using sObject in this 3 different objects will recive based on object i want to identify like(sObjectType == Obj1__c.sObjectType)  and pass the grand parent id into map like(GP GPid = GPMap.get((Id)sObj.get('GPids'));)

Thanks & Regards,
Suresh
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Suresh,
 May I request you to please refer the below link for reference. I hope it will be helpful.

Best Regards
Rahul Kumar
Suresh(Suri)Suresh(Suri)
Hi Rahul,

Thanks for your quick reply, i have written a formula(GPids) field on child object(Childobj) like
Parent1__r.Parent2__c am getting an grand parent id
I want to just conform this formula is it work in 
 for (SObject SO : SOstoSend){
GP GPid = GPMap.get((Id)sObj.get('GPids'));)
}
shall i retrive the grand parent id using this way in apex?