6

Been getting the error:

Cannot set sharingModel to ControlledByParent on a CustomObject without a MasterDetail

this morning when editing/adding fields to some custom objects that are in a master-detail chain and then doing a:

sfdx force:source:push

Re-created the scratch org a couple of times to work around this. But how to work around this in a less time consuming way?

1 Answer 1

12

Based on the workaround from Cannot set sharingModel to ControlledByParent on a CustomObject without a MasterDetail relationship field:

Workaround:
Add the master-detail lookup field to the deployment (even if it has not changed) to your deployment selected list.

it looks like the problem is that sfdx fails to push the master-detail relationship field when it doesn't change.

Until sfdx is fixed to address this, a simple workaround is to manually change e.g. the label of the master-detail field so it does get pushed at the same time as the other changes:

<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>Policy__c</fullName>
    <externalId>false</externalId>
    <label>Policy XXX</label>

and try hard to remember to change it back to the correct value straight after and do another push...

If you have a better solution please post an answer and I will accept it.

2
  • 4
    Putting just a comment works as well <!-- -->
    – Aequitas
    Jul 16, 2018 at 1:53
  • 1
    Automated this by adding a timestamp comment to our master detail metadata files while pushing. May 17, 2019 at 13:44

You must log in to answer this question.

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