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
sravanthi bhavanamsravanthi bhavanam 

API to determine Master-Detail or Lookup relationship

How do we find if a given field is part of a Master-detail or a lookup relationship? Using SOAP API, the describesObjectResult
 has childobjects that does not have the relationship type.

 
SijuSiju
There is one method getRelationshipOrder() method available in the DescribeFieldResult .
For Master-Detail relationships you will get 0 or 1    and  for lookup relationships you will get NULL
 
sravanthi bhavanamsravanthi bhavanam
@Siju
Per the documentation (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_describesobjects_describesobjectresult.htm), it says that the getRelationshipOrder() can never be null. I have also checked while retrieving a lookup field which is not null.
"The type of relationship for a master-detail relationship field. Valid values are:
0 if the field is the primary relationship
1 if the field is the secondary relationship"
SijuSiju
That's correct because there is no method called getRelationshipOrder()  available for lookup field , so it will return null that way you can find the given field is Master detail or lookup 
sravanthi bhavanamsravanthi bhavanam
@Siju
I am using SOAP API and the value is never null. It is always either 0 or 1. This poses issues in actually using this field.
SijuSiju
In that case, create a custom Webservice and use the same logic in the class.