2

I have some custom object - TestObj1, TestObj2, TestObj3....

TestObj1 - Only have 2 Master-Detail fields(With TestObj3 and TestObj4 Objects)

TestObj2 - I have Master-Detail with TestObj5

 now Why can not create this relationship
 TestObj2 object - Master-Detail relationship with TestObj1

2 Answers 2

4

As per Salesforce documented here: You cannot create a master detail relationship with a object which is a junction object. Please find the screenshot below:

Custom junction objects can't have detail objects. That is, a custom junction object can't become the master object in a multilevel master-detail relationship.

enter image description here

1

There are few things you need to consider:

  1. Relationship Limits: Each custom object can have up to two master-detail relationships and many lookup relationships. Each relationship is included in the maximum number of custom fields allowed. So if you are exceeding the number of fields allowed, you may not be able to create the relationship. In your case, i believe you aren't exhausting this limit.

  2. Multilevel Relationships: You can have up to three custom detail levels. Custom junction objects can't have detail objects. That is, a custom junction object can't become the master object in a multilevel master-detail relationship. This seems to be your case.

  3. There is already data present in the object on which you are trying to define the Master Detail relationship - Salesforce will not accommodate a master detail relationship to a custom object that already contains data.

The solution for pt. 3:

Possible workaround is to delete the data in your custom object, and then add the master-detail relationship.

If you don't want to lose all of your existing data, another approach is as follows:

i. 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".

ii. Add a valid value in the lookup (foreign key) field of each data record in the custom object. (You may need to create a custom tab to facilitate this data entry.)

iii. Edit the object relationship and change the relationship type from Lookup to Master-Detail.

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.