Junction objects are custom Salesforce objects that can relate and link two objects. The junction object does this by establishing a master-detail relationship. This post will tackle about how to create a junction object, and how to start a master-detail relationship through the junction object.
Overview of Creating Junction Objects
Junction objects generally start off from a new custom object. After defining a new custom object, the user proceeds to define a master-detail relationship between the objects he wishes to link together.
Create a New Custom Object
Follow these steps to create a new custom object:
- Navigate to Setup.
- On the Quick Find Box, type Objects, then click on it when it appears.
- Hit New Custom Object.
- The Custom Object Wizard will then appear. This wizard walks users through the custom object creation process. A user needs to add the fields needed in the custom object he’s creating. Follow along the wizard’s steps to complete these fields.
- Reminder: Users need not create a tab on the Custom Tab wizard. Junction objects work without tabs and can stand alone by themselves.
- Save everything. A new custom object is now up. This object will serve as the junction object later on.
Define the Master-Detail Relationship
Now that the user has a new junction object, he can start defining two master-detail relationships to link objects together.
Start by defining the primary relationship first.
- Open the new custom junction object.
- Navigate to the Custom Field Wizard.
- Select Master-Detail Relationship under the field type.
- Choose one object that will link to the junction object. Click on that object. Now, this first linked object holds the primary relationship distinction.
- Define the Sharing Setting options. This feature determines user access to the master records. Changes and sharing of master records will affect the corresponding associated records as well.
- Rename the Related List Label, and do not use the default name. Input the name of the other master record object instead.
Now, the user creates the second master-detail relationship. This becomes the secondary relationship. Open the junction object and follow the same steps as above. The user needs to select the other master object that needs to link to the junction object.
Once done, the user has already successfully used the junction object to create links between two separate but related objects.