How to Create a Junction Object in Salesforce

Do you want to create a junction object in salesforce? I will also explain how to create a junction object in salesforce. We will also discuss, how to create a custom junction object in salesforce. Also, we will cover these topics.

  • What is a junction object in salesforce
  • How to create a junction object in salesforce
  • How to create junction object in salesforce lightning
  • How to create junction object in salesforce classic
  • How to make junction object in salesforce
  • How to create a custom junction object in salesforce

What is a junction object in salesforce

A junction object in salesforce is defined as a single term that can be called a custom object with two master-detail fields.

The salesforce permits the use of junction object that enables many-to-many relationship. It is the type of custom object that permits the link between one custom object or one instance to many children’s records, every child can identically link to many parents.

The junction object is used in which we can link custom objects with many child records and join every child record to many parent objects.

Now we have understood Junction Object, let’s move ahead and see how to create junction object in salesforce. We will explore both the salesforce experiences: Salesforce lightning and Salesforce Classic.

How to Create junction object in salesforce

Let’s see the best practices for the creation of the junction object in salesforce:

The junction object is a many-to-many relationship. It is a custom object with Two Master-Detail fields on it.

The first master detail created on the junction object is called Primary Master.

The second master detail is created on the junction object called the secondary Master.

Whoever is the owner of the primary master will be the owner of the corresponding junction (child records).

If we delete any one of the master records the child record will also be deleted.

The child record cannot be deleted if the master record has more than 200 child records.

The Junction object cannot be the master to any of the other objects.

Furthermore, let’s learn how to create a junction object in salesforce lightning.

Read How to Create Records in Salesforce

How to create junction object in salesforce lightning

Salesforce Lightning is a modern view of the salesforce platform that is fast, easy, and filled with a wide variety of options.

Here we are creating the Junction object that is USA student to group.

Follow the below steps on how to create a junction object in salesforce lightning:-

Step-1: Create the custom object, Go to the Setup and click on the Object Manager.

How to create junction object in salesforce lightning
How to create junction object in salesforce lightning

Step-2: After clicking on the Object Manager, the object manager page is open. click on create and then click on the custom object.

How to create junction object in salesforce
How to create a junction object in salesforce

Step-3: After clicking the custom object in salesforce there will be a label option. For the label, enter USA student. After entering the label there is a Plural Label option. For Plural Label, enter USA students. After that, you can see that the Object Name and Record Name are automatically filled.

Create a new custom object
Create a new custom object

Step-4: After filling in all the entry wizards scroll to the bottom of the page and select the checkbox Launch New Custom Tab Wizard after saving this custom object and then click on the save option.

Save the creating object
Save the creating object

Step-5: On the Page of the New Custom Object Tab, there is a Tab Style field click on the field and select a style you like.

Creating a tab for new custom object

Step-6: Click Next, Next, and Save.

Save the creating tab
Save the creating tab

Step-7: After creating the USA student object in salesforce, we create one more object called the USA group. This object is created as same as the USA student object.

Now we are creating a relationship. for creating this we are creating another object that is a junction object.

Creating the junction object in salesforce
Creating the junction object in salesforce

Step-8: After entering the object name enter the Record Name label and Format. The Datatype is in the form of Auto Number. Fill in the display format and starting number. After that Allow the search and click on save.

Saving the junction object in salesforce
Saving the junction object in salesforce

Step-9: After creating the junction object now we are creating a field and relationship for the junction object. Click on the field and relationships option that is present on the left sidebar.

Creating field and relationship for junction object
Creating field and relationship for junction object

Step-10: After clicking on the field and relationships, now click on the Master-Detail Relationship custom field and then click on next.

Creating master detail relationship
Creating master-detail relationship

Step-11: Now we are choosing the related object as a USA student for the new relationship. The USA student is our primary master. After selecting the object click on next.

Selected the primary master
Selected the primary master

Step-12: After selecting the primary master, enter the label and name for the lookup field. The label is USA student and the field name is USA_student. After entering both clicks on next.

creating new relationship
creating new relationship

Step-13: Click Next, Next, and then Add the custom related list, and after that click Save & Next option.

New relationship is created
A new relationship is created

Step-14: Clicking on the field and relationships and then click on the Master-Detail Relationship custom field and then click on next.

Creating new master detail relationship
Creating a new master-detail relationship

Step-15: Now we are choosing the related object as a USA group for the new relationship. The USA group is our secondary master. After selecting the object click on next.

A new relationship is created

Step 16: After selecting the primary master, enter the label and name for the lookup field. The label is USA group and the field name is USA_group. After entering both clicks on next.

Click Next, Next, and then Add the custom related list, and after that click Save & Next option.

Secondary relationship is created
The secondary relationship is created

This is how we understand how to create junction object in salesforce lightning.

How to create junction object in salesforce classic

Salesforce classic is the traditional user experience of salesforce and before the salesforce lightning was introduced, it was the only salesforce experience.

Follow the below steps on How to create a junction object in salesforce classic:-

Step-1: Firstly login to the salesforce account, and then scroll to the bottom of the page you can see that on the left side there is a build option under the build option there is a create option, and click on the create drop-down sign.

After clicking on the Create drop-down menu there will see an objects option click on objects.

How to create junction object in salesforce classic
How to create junction object in salesforce classic

Step-2: After clicking on the objects the Custom Objects page will open, and there is a New Custom object option click on it.

How to create junction object
How to create junction object

Step-3: After clicking on the New Custom Object there will be a label option. For the label, Project USA. After entering the label there is a Plural Label option.

For Plural Label, enter Projects USA. After that, you can see that the Object Name and Record Name are automatically filled then click on save & Next. This Project USA is the Primary master.

Create a primary master object
Create a primary master object

Step-4: After selecting the Save&Next. Now create the secondary master object, there will be a label option. For the label, Developer USA. After entering the label there is a Plural Label option.

For Plural Label, enter Developer USA. After that, you can see that the Object Name and Record Name are automatically filled then click on save & Next.

Create a secondary master object
Create a secondary master object

Step-5: After selecting the Save&Next. Now create the junction object, there will be a label option. For the label, Assignment USA. After entering the label there is a Plural Label option.

For Plural Label, enter Assignment USA. After that, you can see that the Object Name and Record Name are automatically filled then click on save.

Create a junction object in salesforce classic
Create a junction object in salesforce classic

Step-6: After creating the junction object, now create the tab for the primary master object.

Scroll to the bottom of the page you can see that on the left side there is a build option under the build option there is a create option, and click on the create drop-down sign.

After clicking on the Create drop-down menu there will see a tab option click on the tab. The custom tab Page is open, click on the New option.

create tab for primary master
create a tab for the primary master

Step-7: After clicking on the New option, the New custom object tab page is open then select the object. Here we are selecting the primary master object Project USA then select the tab style and after that click on the next option.

Enter the detail of primary master tab
Enter the detail of primary master tab

Step-8: After choosing the tab, click Next, Next, and then Save.

Save the primary master tab
Save the primary master tab

Step-9: Now creating the secondary tab, again click on the New option, New custom object tab page is open then select the object. Here we are selecting the secondary master object Project Developer then select the tab style and after that click on the next option.

Create a secondary master tab
Create a secondary master tab

Step-10: After choosing the tab, click Next, Next, and then Save.

Saving the secondary master tab
Saving the secondary master tab

Step-11: Now creating the junction tab, again click on the New option, New custom object tab page is open then select the object. Here we are selecting the junction object Project Assignment then select the tab style and after that click on the next option.

Creating a junction object tab
Creating a junction object tab

Step-12: After choosing the tab, click Next, Next and then Save.

Saving the junction object tab
Saving the junction object tab

Step-13: After creating the tab click on the junction object, After clicking on the object, Go to a custom Fields & Relationships and click on the New button.

Create filed and relationships
Create filed and relationships

Step-14: After clicking on the New option, the New Custom Field page is open, select the master-detail relationship custom field and click on next.

Create master detail relationship in salesforce
Create a master-detail relationship in salesforce

Step-15: Now select the other object to which the object is related and click on the next option.

Assignment USA new relationship related to Project
Assignment USA new relationship related to Project

Step-16: Enter the Field Label and Field Name for the lookup field. After entering both clicks on next.

Enter the new relationship detail of primary master
Enter the new relationship detail of the primary master

Step-17: Click Next, Next, and then Add the custom related list, and after that click Save & Next option.

Saving the primary master junction object
Saving the primary master junction object

Step-18: After clicking on Save&Next, Field and Relationships page is open then click on the data type Master-Detail Relationship and then click on next.

Create master detail relationship of secondary master
Create master-detail relationship of secondary master

Step-19: Now select the other object to which the object is related and click on the next option.

Assignment USA new relationship related to developer
Assignment USA new relationship related to developer

Step-20: Enter the Field Label and Field Name for the lookup field. After entering both clicks on next.

Click Next, Next, and then Add the custom related list, and after that click on the save option.

Saving the new junction object in salesforce
Saving the new junction object in salesforce

So, with this, we understand how to create a junction object in salesforce classic and now you proceed with the further actions on how to make a junction object in salesforce.

Read How to Use Chatter in Salesforce

How to make a junction object in salesforce

The salesforce permits the use of junction object that enables many-to-many relationship. The First Master Detail created on the junction object is called Primary Master. The second Master Detail is created on the junction object called the secondary Master.

Follow the below steps on How to make a junction object in salesforce:-

Step-1:  From the setup, search for the schema builder in the Quick Find Box. By simply typing schema builder.

How to make junction object in salesforce
How to make junction object in salesforce

Step-2: Create a new object by simply clicking on the element tab that is present in the left sidebar. After clicking on the element tab then drag the object onto the canvas.

How to make junction object in salesforce lightning
How to make junction object in salesforce lightning

Step-3: Create the object you want and enter the information to define your object.

For the label, USA Project. After entering the label there is a Plural Label option. For Plural Label, enter USA Projects. After that, you can see that the Object Name and Record Name are automatically filled then click on Save.

Make junction object in salesforce
Make junction object in salesforce

Step-4: Create the USA Employee and USA Project Task as same we created in step three.

Make junction object in salesforce lightning
Make junction object in salesforce lightning

Step-5: After creating the objects, drag-drop the Master-detail field onto the USA Project task object and fill in all the details and click on the save button.

Create a Master detail relationship between USA Project and USA Project task
Create a Master detail relationship between USA Project and USA Project task

Step-6: Again drag-drop the master detail onto the USA Project task, this time create a relationship between the USA Project task and USA employee. Fill in all the details and click on the save button.

Create a master detail relationship between USA Employee and USA Project task
Create a master-detail relationship between USA Employee and USA Project task

Step-7: After saving the Master-Detail Field you can see that the relationship between the objects is created through the junction object.

The junction object relationship is created
The junction-object relationship is created

So, in this way we have learned how to make junction object in salesforce.

Read How to Create a Task in Salesforce

How to create a custom junction object in salesforce

Junction objects create a many-to-many relationship between the salesforce objects. Costco is a retail company that is establishing a new branch in Washington, USA and they are hiring new employees. For this, they are using the Junction object.

Follow the below steps on how to create a custom junction object in salesforce:-

Step-1: From the setup, search for the schema builder in the Quick Find Box. By simply typing schema builder. The schema builder option is shown, click on that.

How to create custom junction object in salesforce
How to create a custom junction object in salesforce

Step-2: Create a new object by simply clicking on the element tab that is present in the left sidebar. After clicking on the element tab then drag the object onto the canvas.

How to create custom junction object in salesforce
How to create a custom junction object in salesforce

Step-3: Create the object you want and enter the information to define your object. For the label, Applicant. After entering the label there is a Plural Label option.

For Plural Label, enter Applicants. After that, you can see that the Object Name and Record Name are automatically filled then click on Save.

Create custom junction object in salesforce
Create custom junction object in salesforce

Step-4: Create one custom object as job position and also created a junction object called job application same as we created above.

Create custom junction object in salesforce classic
Create a custom junction object in salesforce classic

Step-5: Drag-Drop the master-detail field onto the job application(junction object) for creating a many-to-many relationship between the custom object(Applicant).

Custom junction object in salesforce
Custom junction object in salesforce

Step-6: Again drag-drop the master-detail onto the Job Application, this time create a relationship between the Job Application and Job Position. Fill in all the details and click on the save button.

Custom junction object in salesforce classic
Custom junction object in salesforce classic

Step-7: After saving the Master-Detail Field you can see that the relationship between the objects is created through the junction object.

Custom junction object is created
A custom junction object is created

This is how we understand how to create custom junction objects in salesforce.

Conclusion

In this tutorial, we have learned how to create junction object in salesforce, and also we have covered how to create custom junction object in salesforce. This can be performed on both salesforce lightning and salesforce classic.

  • What is a junction object in salesforce
  • How to Create junction object in salesforce
  • How to create junction object in salesforce lightning
  • How to create junction object in salesforce classic
  • How to make a junction object in salesforce
  • How to create a custom junction object in salesforce

You may like the following salesforce tutorials: