10 个回答
Hi Prema,you can use the below schema class to get the child objects details based on parent:just execute the below class in the debug you can see the list of childs:Schema.DescribeSObjectResult R = Contact.SObjectType.getDescribe(); ///// use the any object instead of contact here List<Schema.ChildRelationship> C = R.getChildRelationships();
integer i = 1;
for(Schema.ChildRelationship rel:C){
if (rel.getChildSObject().getDescribe().fields.getMap().get('Name') != null)
{
System.debug(i + ' @@@ Child Name '+rel.getChildSObject());
// System.debug(i + ' @@@ Rel Name '+rel.getRelationshipName());
i++;
}
}https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_ChildRelationship.htm⌗apex_Schema_ChildRelationship_methodshttp://sfdcsrini.blogspot.com/2015/05/schemadescribesobjectresult-in-apex-and.htmlhttps://salesforce.stackexchange.com/questions/119832/get-the-specified-child-relationship-name-from-parenthttp://salesforce-walker.blogspot.com/2012/12/getting-child-relationshipnames-using.htmlCan you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!Thanks,Raj