How to Create Junction Object in Salesforce

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:

  1. Navigate to Setup.
  2. On the Quick Find Box, type Objects, then click on it when it appears.
  3. Hit New Custom Object.
  4. 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.
  5. Reminder: Users need not create a tab on the Custom Tab wizard. Junction objects work without tabs and can stand alone by themselves.
  6. 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.

  1. Open the new custom junction object.
  2. Navigate to the Custom Field Wizard.
  3. Select Master-Detail Relationship under the field type.
  4. Choose one object that will link to the junction object. Click on that object. Now, this first linked object holds the primary relationship distinction.
  5. 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.
  6. 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.

Leave a Reply

Close Menu