Junction Object In Salesforce

Junction Object:

· J  junction Object is an Object in salesforce it helps to maintain many-to-many relationship between two objects.

·     Let's Create One Example: online Ecommerce Section Management

Custom Object:-Section__c

SectionID

SectionName

IsActive

1

New coming Book

true

2

Best Deal

True

3

Deals Of The day

True

Custom Object:- ProductMaster__c

ProductID

ProductName

IsActive

1

Iphone 5

true

2

Iphone5s

True

3

Iphone6

True

Custom Object:-SectionProductMaster__C

ProductSectionID

SectionID

ProductID

1

1

3

2

1

4

3

2

1

SectionProductMaster__c is Junction Object For Section__c and ProductMaster__c Object.


Product Master Data

Section Master Data

The Below image shows junction object Record (Many-to-Many relationships),

 

SOQL: 

  1. select id,name,(select id from SectionProductMasters__r) from section__c   
 
  1. select id,name,(select id from SectionProductMasters__r) from ProductMaster__c  
Note: Junction objects allow you to track multiple records at once in either direction.

Delete:

Whenever you delete a record from master object like Section__c, ProductMaster__c its automatically deleted over SectionProductMasters__c

OpportunityLineItem,PriceBookEntry are standard junction objects in salesforce. 

Ebook Download
View all
Learn
View all