Salesforce provides multiple types of relationships in order to connect objects together in different ways. You may familiar with two main relationship type Lookup relationship & Master-Detail relationship. These relationships allow you to create a parent-child relationship which is referred to as a one-to-many relationship, which means there is only one parent but multiple child records can be associated. But if we want to create a many-to-many relationship in Salesforce, the Junction object will come in the role.
A junction Object is a type of custom object which allows linking between two custom objects. In simple terms, we can say that Junction Object in Salesforce is a custom object with 2 master detail fields.
Let’s take an example to understand more about the Junction object.
Example: Take a recruitment process where you have a Job Position and Candidate object. As a candidate can apply for multiple job positions, as the standard parent-child relationship will not work. You need a junction object, called application to allow many candidates to apply for multiple jobs.
Steps to Create Junction Object in Salesforce
Step 1: Firstly make sure you have available the two objects you wish you connect with the junction object. I am going to create 2 objects Job Position and Candidate
Step 2: Next, we need to create new custom objects named “Job Application” which act as a Junction object. This object enables us to connect the Job position and Candidate object.
Step 3: We now need to create two Master-Detail relationship fields on the Job Application object. One will need to be our candidate object and the other is the Position object. We can simply create fields with the Master-Detail relationship field type.
If we check this relationship on schema builder it would look something like this.
From the above steps, we can assign many candidates to many job positions.
I hope you like this tutorial and if you want any help let me know in the comment section.
Stay tuned, there is way more to come! follow me on Youtube, Instagram, Twitter, and LinkedIn. So you don’t miss out on all future Articles and Video tutorials.
. . .
I am delighted that you read my article! If you have any suggestions do let me know! I’d love to hear from you. ????
About the Author
Shubham Agarwal is a passionate and technical-driven professional with 5+ years of experience in multiple domains like Salesforce, and iOS Mobile Application Development. He also provides training in both domains, So if you looking for someone to provide you with a basic to advance understanding of any of the domains feel free to contact him