function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Frank MamoneFrank Mamone 

Nested Master-Detail Relationship

Hi,

 

I'm a little confused about this question because I got different answers from different sources.

 

At a recent SF event, I asked the instructor if we could grandfather M-D relationships. What I meant was that a child can be a master of another object.

 

The answer was yes, with limiting factors on Roll-Up Summanries.

 

However, I tried this by creating a new object and then trying to  use it as a child of an object that already was a child of another, and the option is grayed out.

 

Also, in Jason Ouellette's excellent book "Development with the Force.com Platform", on page 41 paragraph 3:

 

"Up to four nested levels of Master-Detail relationships can be created, counting from the master object to the most deeply nested child object".

 

What's the deal?

 

Thank you in advance..

 

Frank Mamone

Certified Developer SP 13

Best Answer chosen by Admin (Salesforce Developers) 
kreshokresho

When you add a masetr/detail relationship to an object, the object on which you created the relationship becomes the detail side. In the next screen you pick its master from a picklist. Here is screenshot of schema viewer in my org (the relationships are totally meaningless, created only for this example.

 

Regards,
Kresimir
Apex Editor LS - free alternative to Force.com apex editor.
Give kudos (click star next to my icon) if this was useful

All Answers

kreshokresho

According to this it should be possible since Summer '10.

 

I tried it upwards (instead of downwards like you did). First created two objects, set up master-detail and then tried to create a master-detail relationship from the master to another object. All worked fine until the final step when I got this error:

 

Cannot Create Master-Detail Relationship

You cannot create a new Master-Detail relationship on an existing custom object if records already exist. You must first create a Lookup relationship, populate the lookup field with data in all records, and then change the relationship type to Master-Detail. 

 

It looks to me it would be possible to chain multiple objects into a master-detail hierarchy had I not hit this limit.

 

Regards,
Kresimir
Apex Editor LS - free alternative to Force.com apex editor.

Frank MamoneFrank Mamone

Hi Kresmir,

 

If I understand correctly, you used the same object as a Master. That would work as long as you don't try to create more than 2.

 

What I'm trying to do is create a 3+ level relationship. 


For example Account => Cities => Addresses

 

So Account would be the parent of Cities, and Cities the parent of Addresses.

 

The actual test I did was from the recruiting app.

 

Position ==> Job Application ==> Custom Object Test

 

Thanks,

 

Frank Mamone

kreshokresho

When you add a masetr/detail relationship to an object, the object on which you created the relationship becomes the detail side. In the next screen you pick its master from a picklist. Here is screenshot of schema viewer in my org (the relationships are totally meaningless, created only for this example.

 

Regards,
Kresimir
Apex Editor LS - free alternative to Force.com apex editor.
Give kudos (click star next to my icon) if this was useful

This was selected as the best answer
Frank MamoneFrank Mamone

 

 

I'm not sure what I did initially to make it gray out...this works.

 

Thank you.