Creating a Many-to-Many Relationship

Creating a Many-to-Many Relationship - master-detail relationships are used to model many-to-many relationships between any two objects. A many-to-many relationship allows each record of one object to be linked to multiple records from another object and vice versa. When modelling a many-to-many relationship, a junction object is used to connect the two objects to relate to each other.

Junction Object: Is a custom object with two master-detail relationships.

Using a custom junction object, a “many-to-many” relationship can be modelled between two objects.

Creating the many-to-many relationship consists of:
  1. Creating the junction object.
  2. Creating the two master-detail relationships.
  3. Customizing the related lists on the page layouts of the two master objects.
  4. Customizing reports to maximize the effectiveness of the many-to-many relationship.
The first master-detail relationship you create on your junction object becomes the primary relationship, and so the junction object acquires Look and Feel, Record Ownership and the Division, if Divisions used in the organisation form the primary relationship.
The second master-detail relationship you create on your junction object becomes the secondary relationship. If you delete the primary master-detail relationship or convert it to a lookup relationship, the secondary master object becomes primary.


  1. Create a Junction object.
  2. Relate to primary object in master detail relationship
  3. Relate to the secondary object in the Master Detail relationship.
  4. Customise both Primary and Secondary objects Layouts to display the junction object’s and other objects fields – edit related listsàJunction Object section in layout editor.
  5. Fields from other objects in the Masters are available in the record’s detail page under related ListsàJunction Object’s section i.e.  junction objects Section – details from both the junction object and the other master are available here. But in junction object the master objects fields are directly available as fields (the Master Detail relationship itself is created by inheriting the field of Master as fields for the Detail object) 

Comments

Popular Posts