You need to sign in to do that
Don't have an account?
Satish Prajapat
find relationship between two unknown object
I have 2 objects may be a standard or custom objects, I want to know which the parent or which is child object??
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
<pre>
static Boolean isAaChildOfB( String sObjectNameA, String sObjectNameB )
{
for ( Schema.ChildRelationship chRel : Schema.getGlobalDescribe().get( sObjectNameB ).getDescribe().getChildRelationships() )
{
if ( String.valueOf( chRel.getChildSObject() ) == sObjectNameA ) return true;
}
return false;
}
</pre>
All Answers
If you want to know the relationship between existing object ,then you can go the object fields there you will find the relationship .
Assume you have object A and Object B .then if A is parent and B is child then when you wil go the fields of object B you will find a field which is either look up or master detail .
Just like below image
Let me know if u have any doubt .
Thanks
Manoj
I want the solution in apex programming point of view not admin point of you.
because I am writing the code where i have list of object and i want to know the relationshiip among all the object. So, for initial level how can I know the relationship between two object.?
<pre>
static Boolean isAaChildOfB( String sObjectNameA, String sObjectNameB )
{
for ( Schema.ChildRelationship chRel : Schema.getGlobalDescribe().get( sObjectNameB ).getDescribe().getChildRelationships() )
{
if ( String.valueOf( chRel.getChildSObject() ) == sObjectNameA ) return true;
}
return false;
}
</pre>
This is also working.