Loading

'Cannot set sharingModel to ControlledByParent on a CustomObject without a MasterDetail relationship field' error

Publiceringsdatum: Jun 3, 2026
Beskrivning

When trying to deploy an update to a custom object from Sandbox to Production in Salesforce, you may receive the following error:
"Cannot set sharingModel to ControlledByParent on a CustomObject without a MasterDetail relationship field."

This error occurs when deploying a child object in a Master-Detail relationship without including its Master-Detail relationship field in the deployment package. For example, if you have ObjectA (the master) and ObjectB (the child object with a Master-Detail relationship field pointing to ObjectA), and you deploy only ObjectB's metadata without its Master-Detail field, Salesforce cannot validate the sharing model (ControlledByParent) because the relationship field is missing from the deployment.

This error typically occurs when deploying only the child object (ObjectB) without including its Master-Detail relationship field, even if that field itself has not changed.

Lösning

How to Resolve the Deployment Error

To resolve this error, add the Master-Detail relationship field from the child object (ObjectB) to your deployment package, even if the field has not been modified.
In Salesforce, a "Change Set" is a deployment tool used to move metadata such as custom objects and fields from one Salesforce org to another (for example, from Sandbox to Production). To add the required field to your Change Set:

  1. Navigate to Setup > Deployment > Outbound Change Sets and open the Change Set you are deploying.
  2. In the Change Set Components section, click Add.
  3. In the Component Type dropdown, select Custom Field.
  4. Search for and select the Master-Detail relationship field from ObjectB (the child object).
  5. Also add all other custom fields on ObjectB to the Change Set to ensure completeness.
  6. Save the Change Set, upload it to Production, and deploy.

After including the Master-Detail field in the deployment, the error will not occur.

Knowledge-artikelnummer

000386883

 
Laddar
Salesforce Help | Article