You need to sign in to do that
Don't have an account?
Anusha
Re : How to get the Chiled Object Name
Hello evryone,
i have a small issue that,
One of my reqirement is, I'm passing a Recod Id from page to Class using param, now using that record Id I need to find the Child Relations on the Object.
Please help me........................
Do you want to fetch the child objects of a sobject?
Yeah,
If know that, please tell me
use below generic fuction to get list of Fields who has child Relationships with specified sobject type.
List<Schema.SObjectField> getChildRelationshipsFields(Schema.sObjectType objType)
{
String strResult = null;
//Sobjetct obj = new Account();
//Schema.sObjectType objType = obj.getSObjectType();
Schema.DescribeSObjectResult ObjResult = objType.getDescribe();
getChildRelationships List<Schema.ChildRelationship> lstChild = ObjResult.getChildRelationships();
List<Schema.SObjectField> lstFields = new List<Schema.SObjectField>();
for(Schema.ChildRelationship objChild : lstChild)
lstFields.add(objChild.getField())
return lstFields;
}
Please try the above code the get child objects.