I am configuring a many-to-many relationship between custom object and Contact. For this purpose I created a junction object. Next, I have to create 2 Master-Detail relations. One for custom object, another for Contact. When creating a Master-Detail relationship field, my custom object is not visible among other objects. What could cause this problem?
3 Answers
There are a few rules that may help you. A custom object cannot be the master to a standard object. Master detail relationships can only be created where there are not existing records in the object on the detail side of the relationship. If this does not help you, it would help to have more information on what objects are masters and which objects are being used for detail. Thanks
I found the answer. Only two Master-Detail relationships are allowed per custom object. My custom object already had 2 Master-Detail relationships. I converted one field to lookup. After that, I was able to see this object among other objects when creating a Master-Detail relationship on junction object.
The Exception is self explanatory here and you have to remember the rules while creating the relations between objects (tables in salesforce).
Exception: 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.
Rules to follow while making Master Detail Relationship
- Standard Object to Custom Object
- Custom Object to Custom Object
- Standard Object cannot be on the detail side
Lead
andUser
objects cannot be the part of Master Detail relationship
In case if you have some records inserted already and later you want to establish Master Detail relationship then first you need to create the lookup relationship and relate each record, then change the relationship type to Master-Detail.
For many to many relationship you have to create third table(Junction Object) with id fields of each table.
You can have up to three custom detail levels
i.e.., if childObj1 is already a great-grand child of another masterObj1, you could not be able set this childObj1 as master to another object. help.salesforce.com/…