3

I seem to be unable to create a custom field of the master-detail type. Because each time I create one and try to push it to another scratch org I get this error message : 

Cannot set sharingModel to ReadWrite on a CustomObject with a MasterDetail relationship field

However according to the metadata documentation the only values available are Private, Read and ReadWrite. Can't seem to wrap my head around this problem.

Did anyone encountered this problem already ?

3

Not sure that this is your scenario but I've seen:

Cannot set sharingModel to ReadWrite on a CustomObject with a MasterDetail relationship field

most often when trying to change a field on an object that already has the master-detail field present. The problem appears to be that SFDX is smart (but not quite smart enough) in that it only pushes the field(s) that have changed and so does not push the master-detail field. That then triggers the above error message as described here.

The work-around I use is to also edit e.g the label of the master-detail field (and try hard to not forget to restore the correct label after) so that that field is also pushed.

  • I think the sharingModel field is on the Object file; for a Detail object the only valid value is ControlledByParent. So I'd amend this to "also edit the label / description / anything of the Object" after creating the M-D field. That way DX will be sure to pull the Object file again too, and then other devs should have no trouble pushing that to other orgs. – Charles T Apr 13 '18 at 11:49
  • @CharlesT Maybe worth a separate answer? I've never had a problem with the Object file, just with the scenario in my answer. – Keith C Apr 13 '18 at 13:29
  • @KeithC I am facing the same issue + lot of fields (and App, ...) are not pushed at all. Your workaround is not working. Any other way to do ? – Simon Placentino Apr 16 '18 at 7:39
  • @SimonPlacentino That sounds more like the difference data has got messed up. Suggest you create a new scratch org and push into that. – Keith C Apr 16 '18 at 8:04

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.