Monday, 20 January 2014

What is Junction Object in Salesforce and How to Create it.

Junction Object:
     A custom object with two master-detail relationships. Using a custom junction object, you can model a “many-to-many” relationship between two objects.


To create the junction object:
  1. Click Your Name | Setup | Create | Objects.
  2. Click New Custom Object.
  3. In the custom object wizard, consider these tips specifically for junction objects:
    • Name the object with a label that indicates its purpose, such asBugCaseAssociation.
    • For the Record Name field, it is recommended that you use the auto-number data type.
    • Do not launch the custom tab wizard before clicking Save. Junction objects do not need a tab.

Few important points (Interview Questions of salesforce ):
  1. One Object can have only two Master-Detail relationships.
  2. If we delete record A (First Master detail relationship is always primary)  – then child record c will be deleted.
  3. If we delete record B then in this case also child record C will be deleted.
  4. If we delete record c then only C will be deleted , master record will not be deleted.
  5. If child C has two Master record A and B, Where A is primary relation then Child record C will inherit the look and feel of Parent object A.

 Using a custom junction object, you can model a “many-to-many” relationship between two objects.
A many-to-many relationship consists of three objects: Object A and Object B are the two primary objects, and Object J is the junction that enables the many to many.

Object A  <--M/D--  Object J  --M/D--> Object B

So on Object J you need to create two Master-Detail relationships, one that points to Object A and one that points to Object B.

For More Information:
https://success.salesforce.com/ideaView?id=087300000006tlL

No comments:

Post a Comment