Cannot set field to ControlledByParent on a CustomObject without a MasterDetail relationship field

Jason Mann on

Share with


Solving the Salesforce bug: Master-Detail fields must always be included in deployments

Some objects in Salesforce organizations are linked through relationships. These relationships are managed through custom fields and determine how the objects handle data deletion, record ownership, security and required fields in page layouts (see Salesforce developers guide). One relationship type is Master-Detail. This is a one:many relationship type in which the master (or parent) object controls certain aspects of the behaviour of the detail (child) objects.

There is a known Salesforce bug with master-detail relationships which is a common deployment failure point for many users. It affects change sets and the migration tool, and any other tool which uses the Metadata API.

The bug

In theory, when a change is made to a detail object which doesn’t change the Master-Detail field, the Master-Detail field doesn’t need to be included in the deployment. Users who have been trying this, however, are met with the following error when they run a deployment: Cannot set field to ControlledByParent on a CustomObject without a MasterDetail relationship field.

To work around this bug, the Master-Detail relationship field always needs to be included in the deployment, regardless of whether there’s any change to it. If it isn’t included, the deployment will fail.

How Gearset solves the problem for you

Gearset’s dependency analysis engine automatically detects and works around this bug. When running a deployment with a child object with a master-detail relationship, Gearset will automatically include the Master-Detail relationship field in the deployment, even if there’s been no change to it. This will make sure your deployments don’t fail as a result of this bug.

Catching the master-detail field bug

This is just one example of the many ways Gearset helps you to deploy first time every time. Tired of Salesforce deployments failing too often? Start a free 30-day trial of Gearset and see just how much time and effort you can save.

Try all of Gearset for free