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
Surya KusampudiSurya Kusampudi 

Master Detail Relationship Deployment is Failing

Here is the scenario,

> Create 2 Master Detail relationship fields and 2 Lookup fields on any Custom Object
> Deploy these changes to target Org
> Now convert 1 master-detail relationship to lookup field and 1 lookup field to master-detail relationship field

> Now again deploy this change to the target org and it fails with the below error message.

 

Error: You cannot create this type of field because this object already has two master-detail relationships.
 

Technically, master-detail already converted to look-up relationship so it should just update the field on the target org. But it is not happening?

Any explanation would be helpful?

Best Answer chosen by Surya Kusampudi
VinayVinay (Salesforce Developers) 
Hi Surya,

Salesforce will not accommodate a master-detail relationship or lookup relationship to a object that already contains data.

You would need to add this as post-migration step and convert manually.  Check below reference for more details.

https://help.salesforce.com/articleView?id=000325374&type=1&mode=1

Thanks,