Loading

Unable to create a master-detail relationship

Data pubblicazione: Oct 13, 2022
Descrizione

Salesforce will not accommodate a master detail relationship to a custom object that already contains data.

Risoluzione

This is because creating a master-detail relationship adds a new required field to the custom object (known as a "foreign key" to database administrators). Each data record in the object needs to have a valid value in the field, and cannot be left blank.

  • If the object ( detail ) that is being related does not yet have many records, a possible workaround is to delete the data in the custom object, and then add the master-detail relationship.
  • To preserve existing data, here is another approach:

1. Create a Lookup relationship instead of a Master-Detail relationship. This adds the new "foreign key" field to the custom object, but it is not required to have a value for each data record. Do NOT make the Lookup "required". 
2. Add a valid value in the lookup (foreign key) field of each data record in the custom detail object. 
3. Edit the object relationship and change the relationship type from Lookup to Master-Detail.

Note: This resolution is not applicable for custom metadata types.


See Also:
Object Relationships Overview
Object Relationships on Trailhead

Numero articolo Knowledge

000385231

 
Caricamento
Salesforce Help | Article