Creating a Master Detail Relationship- Some Do’s and Don't s
A Master Detail Relationship is a type of Relationship in Salesforce that links two Custom Objects together, with one object as the "Master" (Parent)Object and the other object as the "Detail" (Child) object. The Master Object controls the behavior of the Detail Object and is responsible for deletion of detail records.
Here are my very first findings while working on the initial chapters on the above topic. I have explained below, when a Master-Detail relationship between two custom objects cannot be created and then what are some common errors we face at the early phases of Relationship creation between two Custom objects and how can we fix those errors and create the Master Detail relationship successfully.
A) You cannot create a Master Detail Relationship if...
Your Detail (Child) Object has data in it that is not populated with a LOOKUP Relationship with the Master (Parent) Object first.
One of the Custom Objects is already a detail (Child) Object in another Master-Detail Relationship.
The Custom Objects you want to create the Master-Detail relationship between have different sharing models, such as Private and Public.
The Custom Object you want to make the Detail (Child) Object has a LOOKUP Relationship with another Object.
The Custom Object you want to make the Master (Parent) Object has roll-up summary fields that reference the Custom Object you want to make the Detail (Child) object.
B) The Second Part of my explanation is with reference to the earlier Section (A 1)
If you already have data inside your Detail (Child) Object, before creating the Master detail relationship, then you have to CREATE a LOOKUP Relationship between both these Custom objects first and then go and Populate the fields inside your Detail (Child) RECORD, where it asks you to input the Master Data Information (See image below).
Once that is done and every field input in the Detail Object is matched with the Master field data, you can then go back to the Detail (Child) Object, and go onto it’s ‘Fields and relationships’ page under edit, click on the LOOKUP relationship you created before with the Master, ‘Change field Type’ (you will find this on top of the edit page) change the Relationship type to ‘Master Detail’ now and check the Re parenting box and save.
Here’s what it says-check the box.
Child records can be reparented to other parent records after they are created
And viola! Your Master detail Relationship is created.
See images of an Example below.
Example- We are Creating a Master detail relationship between two custom objects.
Job Application (Master/Parent)
Click On Each data link to enter and populate the Master data.
You have to either populate these data manually, clicking each one or once you learn the use of data Loader, you can use that.
This may not be the only hurdle I have faced, but to have successfully brainstormed it for over a two days is a great feeling! It is important to carefully consider these restrictions when designing your Salesforce org, as the master-detail relationship is a fundamental aspect of the data model and can impact our data structure and functionality. If these restrictions are not met, we cannot create a master-detail relationship between two custom objects in Salesforce
A Note of Thanks.
I sincerely thank my friend and fellow student Shruti Gangwar SA03 for brainstorming some part of this with me! Teamwork is exciting and rewarding. Always!