For Master-Detail relationship fields, the DescribeFieldResult
has a method called getRelationshipOrder()
, which, according to the docs:
Returns 1 if the field is a child, 0 otherwise.
At first I assumed that this meant that this would always return 1 for any Master-Detail field, but that's not the case.
In testing, it appears that the "order" refers to the order of field creation.
For instance, I created two Master-Detail fields on an object called Test__c
, in this order:
- Account__c: Master/Detail on Account
- Contact__c: Master/Detail on Contact
Inspecting the DescribeFieldResult getRelationshipOrder() for these two fields, Account__c had 1, Contact__c had 0.
Next, I deleted Account__c. This caused Contact__c to have Relationship Order of 1.
I then undeleted Account__c, and made it Master/Detail again. Contact__c retained its Relationship Order of 1, and Account__c took on Relationship Order 0.
So my question is, does getRelationshipOrder()
really just help you determine which Master/Detail field was created first, and if so, what does this matter? Do Master/Detail fields with Relationship Order 1 behave differently than Master/Detail fields with Relationship Order 0 ?