Blog Blog Posts Business Management Process Analysis

What is Junction Object in Salesforce and How To Create It?

There are various relationships in which Salesforce by default allows only one to many and many to one relationship which can be achieved by using various triggers. But what if in an organization there is a manager who wants to access both sales and support team data?

The manager wants to edit, view, and update information in the database. To do this he/she needs access to both sales and support team databases which can be done if he/she is provided with many-to-many relationships or as we say master-detail relationships in Salesforce. This can be done by using Junction Object in Salesforce.

Learn Salesforce in detail by watching the video on Salesforce Tutorial-


What is Junction Object in Salesforce?

Salesforce allows the use of Junction Objects which enables many-to-many relationships. Junction Object is a type of custom object which allows linking one custom object or one custom instance to many children records and each child can equally be linked to many parents.

Junction Object in simple terms can be called a custom object with two master details fields.

Now a common question arrives in all Salesforce interviews: what is the use of Junction Object? The answer is, junction object is used to link one exemplar of a particular record to many child records and many child records to one record respectively.

Applying for a Salesforce Admin job? Check out our blog on top Salesforce Admin Interview Questions and Answers!


Best practices for the creation of Junction Object in Salesforce-


What are Many-to-Many relationships in Salesforce?

A many-to-many relationship allows each record of one object to be linked to multiple records from another object and vice versa.  For example, a many-to-many relationship exists between customers and products: customers can purchase various products, and products can be purchased by many customers.

For a many-to-many relationship in Salesforce, each master object record displays a related list of the associated junction object records. To create a seamless user experience, you can change the name of the junction object-related list on each of the master object page layouts to have the name of the other master object.

learn Salesforce from the scratch with Salesforce Tutorial!


Steps to create a Junction Object in Salesforce

Let’s understand how to create a Junction Object in Salesforce by understanding it with an example- we will be creating three objects namely Project, Project Task, and Employee. Now in this situation master record will be created on Employee and thus, he will be able to access both the project and the project task records.

Step 1 – Open your Salesforce Dashboard.

Step 2 – On the Quick Search tab search Schema Builder. Click and open it. A page will appear

Step 3 – So at first, we are going to create our objects. Let’s create an object by dragging the object from the list shown on the left.

Step 4 – Create a new object named Project -> Add Projects as plural labels. Click on Save after entering the necessary information.

Step 5 – Create another object named Employee -> Add Employees as plural labels. Click on Save after entering the necessary information.

Step 6 – Create another object named Project Task -> Add Project Tasks as plural labels. Click on Save after entering the necessary information.

Step 7 –  All your objects are created now and it will look like this:

Step 8 – Now drag Master Relationship from the list and create a Master Relationship role related to Project.

Step 9 – Now again drag Master Relationship from the list and create a Master Relationship role related to Employee.

Step 10 – Your Junction Object is created. Now you have access to many-to-many relationships in your Salesforce dashboard.


How to query Junction Object in Salesforce?

Creation of Junction Object is done by the following steps but it can also be accessed by the use of SOQL (Salesforce Object Query Language) query too. SOQL query can be used to access the data from the junction object. This can be done in the following way-

SELECT lookup_(Object in Junction)api_name__r.field FROM junction_object_api_name WHERE = '<<main_object_record_id_tag>>'

Interested in learning Salesforce? Enroll in Salesforce Training now!

Become a Salesforce Administrator and App Builder

Points to remember while creating a Junction Object in Salesforce-

Have any questions about Junction Object? Get it cleared on the Salesforce community!

The post What is Junction Object in Salesforce and How To Create It? appeared first on Intellipaat Blog.

Blog: Intellipaat - Blog

Leave a Comment

Get the BPI Web Feed

Using the HTML code below, you can display this Business Process Incubator page content with the current filter and sorting inside your web site for FREE.

Copy/Paste this code in your website html code:

<iframe src="" frameborder="0" scrolling="auto" width="100%" height="700">

Customizing your BPI Web Feed

You can click on the Get the BPI Web Feed link on any of our page to create the best possible feed for your site. Here are a few tips to customize your BPI Web Feed.

Customizing the Content Filter
On any page, you can add filter criteria using the MORE FILTERS interface:

Customizing the Content Filter

Customizing the Content Sorting
Clicking on the sorting options will also change the way your BPI Web Feed will be ordered on your site:

Get the BPI Web Feed

Some integration examples