15

I added my master-detail relationships in the wrong order and need to change my object's primary relationhip. From the docs:

The first master-detail relationship you create on your junction object becomes the primary relationship.

I tried deleting (and erasing) both relationships but when I re-add them the incorrect object is still showing as the primary relationship. Is there a way to change the order without deleting the entire object?

3 Answers 3

10

I had it once and I've eventually managed after some trial & error. Can you go to the "wrong #1" in setup and change field type to Lookup? The other guy should get promoted and when I've flipped it back to M-D it turned out to be the way I wanted. Might have been just a stroke of luck though.

9

I discovered that the relationship order can be found in the object metadata, as relationshipOrder (see snippet):

 <fields>
    <fullName>My Primary MD Field</fullName>
    <relationshipOrder>0</relationshipOrder>
    <type>MasterDetail</type>
 </fields>
 <fields>
    <fullName>My Secondary MD Field</fullName>
    <relationshipOrder>1</relationshipOrder>
    <type>MasterDetail</type>
 </fields>

I tried swapping the order on my two Master-Detail fields and deploying from the IDE but Salesforce would not allow that change to occur. I suspect you would be able to set it as needed for a new object.

3

I have had the same issue and I fixed by switching the relashionship order of my junction object by converting the primary relationship from Master-Detail to Lookup Relationship and then back to Master-Detail. This approach solved my problem with permissions without major changes.

The second master-detail relationship you create on your junction object becomes the secondary relationship. If you delete the primary master-detail relationship or convert it to a lookup relationship, the secondary master object becomes primary (Salesforce, 2013).

References

Salesforce. (2013). Considerations for relationships. Retrieved from http://na6.salesforce.com/help/doc/en/relationships_considerations.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .