What is a Junction Object in Salesforce?

Share this article...

Salesforce provides multiple types of relationships in order for you to connect objects together in different ways.

You may be familiar with the two main relationship types: lookup relationships and master-detail relationships. These allow you to create a normal parent-child relationship, which is sometimes referred to as a 1-to-many relationship. This means there is only ever one parent, but multiple child records can be associated. However, what happens when you need to connect “many” parents to “many” child records? Let’s take a look…

Salesforce Junction Object

Salesforce Junction Objects give you a way to create a many-to-many relationship between Salesforce objects. They are created using a custom object to relate two other objects via two master-detail relationships. This is necessary when modeling certain data schemas. Let’s dive into a couple of examples:

Junction Object Examples

Take a recruitment process where you have a job position and candidate object. As it is a requirement for candidates to apply to multiple job positions, a standard parent-child relationship would not work. You need a junction object, called something along the lines of ‘Application’, to allow many candidates to apply to multiple job positions.

There is also an example within standard Salesforce objects with Opportunity Products. If you want to assign Products to a certain Salesforce Opportunity, you will need to use the Opportunity Line items object (a junction object). This is required as, without the Junction Object, you would only ever be able to associate one product to one opportunity.

Creating a Junction Object in Salesforce

Creating a junction object is simple, and once you’ve created your first one, the concept will become second nature. I’m going to use the recruitment process example from above to makes things simple:

1. Firstly, make sure that you have available the two objects you wish to connect with a junction object. I’m going to create two custom objects: Candidate and Job Position. As you can see from the Salesforce Schema Builder, these are currently disconnected. To ensure that many candidates can apply for many jobs, we need our junction object.

2. The next step is to create a new custom object that will serve as our junction object. I’ve created a custom object called “Job Application”, which will enable us to connect the Candidate and Job Position objects.

3. We now need to create our two master-detail relationships on the Job Application object – one will need to connect to our Candidate object, the other to Job Position. You can do this by creating a field (as normal) on your Job Application object, then navigating to the master-detail relationship field type, and selecting our other objects. If we go back to the Schema Builder, we can see our many-to-many junction object is complete!

From the above setup, we are now able to assign many candidates to many job positions. Let’s have a look at how this looks inside of Salesforce…

Salesforce Example

As you can see in the below image, the junction object has enabled more than one individual to apply for this Salesforce Admin position.

It also allows the individual to apply for multiple job positions within the company…


That’s all there is to it! Junction objects are a core element in understanding how the Salesforce data model works. It’s vitally important to understand, not only for your Salesforce Admin Certification, but also to build scalable solutions in the future. Happy solutionizing!

READ MORE: The 6 Types of Relationships in Salesforce

25 thoughts on “What is a Junction Object in Salesforce?

      1. You can definitely build one. But Master-detail relationships are better suited for junction objects to prevent orphan records.

    1. Christine Marshall


      Hi Mark,

      Was there anything in particular you felt would have been useful? When you say “security” do you mean the sharing model etc?

      Best, Christine

  1. Hi Christine,

    Using the example above, if a user has read access to Candidate object but not to Job Position, if we create the Junction Object, will the user be able to have read access to the Job Position? Sort of security inheritance for objects that the user have no access to. Thanks.

    Best Regards,

    1. When you grant access to the junction object (e.g. via the profile), when you select it, it will automatically select the two parent objects too and won’t allow you to save unless the profile has read access to all 3 objects.

    1. Christine Marshall


      Hi Ken,

      For users to be able to see Application records, they would need to be granted a minimum of Read access via their profile. When you select Read access against Applications, it will automatically select Read access on Job Position and Candidate. If you remove Read access from Job Position or Candidate, it will automatically remove Read access from Applications too!

      Hope this helps!

  2. If we build connection between two parent objects with Lookup relationship or one lookup and another master-detail relationship, wouldn’t it still be called junction object??

    1. Hi Sagar,

      the connection should be common to make an object as a junction object. the junction object functionality should connect both master objects. if u make look-up., it won’t connect both. For ex: Candidate and job position ., both are connected through Application., that’s why it became a junction. so M-D relation with Candidate and Job Position is must., Look-up can’t make them hold always. It’s like by-passing the Application Object. Hope this Helps.

  3. Hello Everyone

    I would like to know if in the example, is possible to create a record of Job position is possible to create a Candidate using all the relationships or the Candidate must be previously created?

  4. What if these need to be deleted after a time period to comply with data retention policy? In what order should the records be deleted in the flow? Or is there an option delete all at once?

  5. Hi, am having one doubt, for example, we are using 3 objects job__c, candidate__c, Job application__c right. for suppose I need to display the list of candidates who applied for a particular job using Data-Table and screen flow likewise I need to display the list of jobs applied by candidates in job detail page. can anyone give me an idea to display the list of candidates and jobs using the junction object?

  6. How many junction objects can the same set of 2 parent objects have together? Is there a limitation on this the same way there is a limitation on the max number of master-detail relationships an object can have?

Add Comment