Today's Offer - Salesforce Certification Training - Enroll at Flat 10% Off.

- Salesforce Blogs -

All you want to know about Junction Object - Salesforce

A Junction is an object which is used to combine two master-detail relationships. In a layman’s language, when two relationships came together injunction, they form one relationship out of the two.

Case 1: One to Many Relationships

Case 2: Many to One Relationship

Result: Many to Many Relationships

We have taken an easy example of a recruitment application which will clarify the meaning and usage of Junction object.

Read: Salesforce Developer Resume Sample – What all you need to Know?

Case 1: There can be only one Position available for a particular job profile. But for that particular job profile, there can be multiple candidates. This is the case of One to Many relationships. That is one job and many candidates. Job Profile Case 2: There can be only one candidate but is eligible for many job profiles. This is the case of Many to One relationship. That is one candidate and many job profiles. One to Many relationshipsResult: To make both of the two cases compatible with each other, we need to create another 3rd case (Salesforce Lookup field) for both the cases that is, job position and candidate. As a result, it will return a kind of filter option using which compatibility of both cases will be found. We will be able to look either for the applicant who is compatible with different job profiles, or the job profile for which multiple candidates are eligible. This is the case of Many to Many relationships.

In Salesforce, there are objects called “Junction.” The Junction objects are used in Salesforce to build relationships in multiple capabilities between the things in Salesforce. When there is a requirement to link several different things with one thing or one object, therefore, there can be many applicants for particular applications. Many examples are relatable to Salesforce Junction object. Like- Car dealership: many vehicles and many Customers, Pharmaceuticals: many medicines and many patients, many educational programs and many students, and much more. salesforce Curriculum There are two fields to achieve Salesforce Junction object. They are both one to many relationships; and they are both defined from many to one side that is, from a child to a parent. They can be made one to one relationship by adjoining validation rules or may trigger to enforce one to one nature; that is, only one child is allowed. Detail of the two fields of Salesforce – Master-detail, and Lookup are given below: -

  1. Master-detail:
    1. The number of master-detail relationships you can utilize are limited
    2. You may not possess detailed report without a master
    3. The detailed record inherits sharing rules from the master
    4. You are not allowed to update the relationship to the master in a master-detail relationship
    5. The numeral of master-detail relationships you can access is limited
    6. You cannot set profile object permissions for a detailed record
  2. Lookup:
    1. Lookups are generally used to reference commonly shared data, For example, reference data
    2. Lookups are used when you are required to relate multiple ‘parents’ to the detailed record
    3. Lookups are commonly used for where you may or may not need to have a relationship between two objects
    4. These are used to link two objects together when you have not required the behavior of master-detail (specifically around sharing rules, cascade delete, and profile permissions)

What are Many to Many relationships in Salesforce?

In M: M relationship, one record o one object is linked to multiple records of another object and vice versa. In Salesforce, there is no pre-availability of Many to Many relationships, but we create them; which is done by creating two master-details relationship with a Junction Object which is common.

Use of Junction Object

It is the most common question which is asked in the interview with Salesforce applicants. It is a custom object which is used to link one exemplar of a record to many child records and many child records to on records equally. Examples are already mentioned above. Now, we will learn step by step procedure to create a Junction object for Many to Many relationships in Salesforce. To create Many to Many relationships, initially, we have to create a Junction object. salesforce quiz

Create a Custom Junction Object

Let us assume we want to relate A and B, and have to create one more object C. C will be the Junction object. Let us start with creating a Custom Junction Object. Initially, we will create an object A. Create a Custom Junction Object Now, we have to create two more objects B and C in the same way as object A is created. Now, we are going to use Object C as a junction object for A and B. Create “First Master-detail” field on the object and select object A as a parent. This will act as the Primary master-detailed relationship. Create a Custom Junction Object In the next view, you have to assign a name to the field. Create a Custom Junction Object For the Master record A, we have assigned the name “ChildOfA” and in the same manner, for B we have assigned the name “ChildOfB”. So, until now, we have created two objects- Object A and Object B. Now we can create a tab for all the custom objects to add the new record. Firstly, create the record A and B and for record C, follow the screenshot below:- Create a Custom Junction Object Things to Remember:-

Read: Salesforce VisualForce Interview Questions & Answers for Fresher, Experienced
  • There is only one Master-detail relationship per object
  • If record A is deleted, then child record associated with it, that is record C will also be deleted
  • If record B is deleted, then child record with this record, that is record C will also be deleted
  • But if record C is deleted, only C will be deleted; the master record will not be deleted and remain same
  • If child C has two masters- record A and B, where A is primary relation then child record C will inherit the look and feel of parent object A

Modify the Page Layouts

Next step is to add fields on the Positions Page layout.

  • From the Setup option, click on Object Manager
  • Click on Position, then Layouts
  • From multi-select menu next to Position layout, select edit
  • Scroll down to the Job postings related list, click on the edit button in the header to edit it.
  • From the available fields section, select
    1. Site: Status
    2. Site: Technical Site
  • Click on Add
  • From the selected Fields section, select Job Posting: Job Posting number and click on remove
  • Click Ok and then Save

Now, add fields to the position related list on the site page layout

  • From Setup, click on the Object manager
  • Click on site, then Page Layouts
  • From multi-select menu next to Position layout, select edit
  • Scroll down to the Job postings related list, click on the edit button in the header to edit it.
  • From the available fields section, select
    1. Position: Status
    2. Position: Title
  • Click on Add
  • From the selected Fields section, select Job Posting: Job Posting number and click on remove
  • Click Ok and then Save

Now, testing for all what you have done

  • Click on the button having a multi-dots graphical picture on it
  • Then click on recruiting
  • Click the Positions tab, then select New then enter the details of the new position
  • Click on save
  • Click on the sites tab, then click on New, and enter the details
  • Click on save
  • On the site record, you just created, click on the related tab
  • On the site related list, click on New
  • For position, search for and select Super sales rep and click on save button

Final Words

Read: How to Get & Reset Security Token in Salesforce Lightning

Object helps in the creation of Many to Many relationships which may consist of:-

  • Creating the Junction Object
  • Creating the two master-detail relationships
  • Customizing the related lists on the page layouts of the two master objects
  • Customizing reports to maximize the effectiveness of Many to Many relationships

free salesforce demo The order of master objects in the report type is important. Other than that, the master object which listed object first determines the scope of records that are displayed in the report. Based on this, you can create custom reports based on these standard based reports. You can also create custom type report to customize which is related to the objects that are joined in the report. Summing up, Salesforce is not just a game player but the game-changing CRM platform.  So ride the wave of Salesforce and explore wider features. If you want to know more about Salesforce, you should take Salesforce training and play around with records that are made specifically for that purpose only.

Salesforce Tutorial Overview


    Janbask Training

    JanBask Training is a leading Global Online Training Provider through Live Sessions. The Live classes provide a blended approach of hands on experience along with theoretical knowledge which is driven by certified professionals.


Trending Courses

AWS

  • AWS & Fundamentals of Linux
  • Amazon Simple Storage Service
  • Elastic Compute Cloud
  • Databases Overview & Amazon Route 53

Upcoming Class

4 days 24 Nov 2019

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing

Upcoming Class

5 days 25 Nov 2019

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning

Upcoming Class

5 days 25 Nov 2019

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation

Upcoming Class

6 days 26 Nov 2019

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

-1 day 19 Nov 2019

Course for testing

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

34 days 24 Dec 2019

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing

Upcoming Class

13 days 03 Dec 2019

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum

Upcoming Class

5 days 25 Nov 2019

SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design

Upcoming Class

-1 day 19 Nov 2019

Comments

Search Posts

Reset

Receive Latest Materials and Offers on Salesforce Course

Interviews