5

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?

8

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
    Putting just a comment works as well <!-- --> – Aequitas Jul 16 '18 at 1:53
  • @Aequitas A better approach for sure. – Keith C Jul 16 '18 at 7:58
  • Automated this by adding a timestamp comment to our master detail metadata files while pushing. – Charles Naccio May 17 at 13:44
  • @CharlesNaccio Nice. – Keith C May 17 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.