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
Leigh RogaloLeigh Rogalo 

How to convert a lookup Relationship to a 2nd Master-Detail Relationship on an object

I understand that an object can have two Master-Detail Relationships.  I currently have a custom object with 1 Master-Detail and 1 Lookup Relationship.  I would like to convert the Lookup to a Master Detail Realtionship.  When testing in sandbox, I am receiving the message that a master-detail already exists.

Has anyone had this scenario and if so, how to work around?

Thanks in Advance!
Best Answer chosen by Leigh Rogalo
David ZhuDavid Zhu
I might understand incorrectly. It seems to me that you want setup two master-detail relationships on the same two custom objects. Then it won't work.

If not the case, according to https://help.salesforce.com/apex/HTViewHelpDoc?id=relationships_considerations.htm&language=en_US
"You can convert a lookup relationship to a master-detail relationship, but only if the lookup field in all records contains a value.".
 

All Answers

Cyrus TalladenCyrus Talladen
Did you mean that a master-detail exist or records already exist?  You can create at most 2 master-detail relationships between two objects unless that object is a junction object.  If you want a situation where that object is the child of two different master objects then that is also possible.  But if records already exist then you may have to remove the existing relationships first before reimplementing new relationships.

Cyrus T
www.levementum.com
 
Leigh RogaloLeigh Rogalo
Hi Cyrus,

I have both - 1 - Master Detail Relationship Plus 1 Lookup Relationship field that are popluated with data.  I want to convert the LookUp Relationship to be a 2nd Master Detail Relationship.
Cyrus TalladenCyrus Talladen
I am assuming that the error really says "records already exist" in which case you have to remove the existing relationships first.
 
David ZhuDavid Zhu
I might understand incorrectly. It seems to me that you want setup two master-detail relationships on the same two custom objects. Then it won't work.

If not the case, according to https://help.salesforce.com/apex/HTViewHelpDoc?id=relationships_considerations.htm&language=en_US
"You can convert a lookup relationship to a master-detail relationship, but only if the lookup field in all records contains a value.".
 
This was selected as the best answer
Leigh RogaloLeigh Rogalo
David,

Thank you for the response.  You are understanding correct - I am trying to create 2 Master-Detail Relationships to the same two objects (Custom Object to Standard Object (Account).