A master-detail relationship defines the relationship between the parent and the child. The master table defines the parent relation and the detail defines the child relation. If the master table is deleted then the child record data is also deleted. The RUS(Roll-Up Summary) fields are also created on master records.
How to create MDR(Master-detail Relationship)?
Let us start with an example, create two different Objects for Master-detail relationship, and have a look at the benefits we have in MDR.
Eg: Two Objects.
- Company Names.
I have included simple fields for “Company Names & Employees” Objects as shown in the below figure.
For MDR, we need to create a relationship field on one of the Objects. Select for strong relationship bonding not as “Lookup relationship”.
I have taken Employees Object and created an MDR field in it. The process includes,
Click on Employees >> Click “Quick Access Menu” >> Add “New Field”.
Step1: Choose Field Type (Master Detail Relationship) >> Next.
Step2: Select the appropriate Object on which the relationship should be established.(eg: Company name) >> Next.
Step3: Fill in the details and proceed to the next step.
Step4: Provide with all the required security level check and proceed to the next step.
Step5: In this step, we will add a reference field for MDR to the page layout and proceed for next step.
Step6: In this step, we will add a custom related list of the desired Object and Save.
Subscribe to our youtube channel to get new updates..!
With the above steps, the MDR relationship is established. The below displays the relationship.
Hence, we can look at the MDR created between the “Company Names and Employees”
Let us add, an New Employee to the Object. We can observe that without the “Company Name” entering, it is unable to proceed to the next step. So, click on the magnifying glass located to the field next to enter “Company name”, you can select the company name for which the employee belongs to.
Note: We can create upto 2 MDR in 1 Object. Not more than that.
To look at the MDR, Field Dependency & Cache clear process, let us assume with an example. Let us create some records in the “Employee Object”.
Let us delete the “Company Name” (eg.Tech Mahindra), from the list and observe the dependency, cascading delete & master-detail relationship work process.
After deleting the “Tech Mahindra” record from the “Company Names” Object list, the dependent employee’s and their records are also deleted from the “Employees” Object. Whereas this scenario is not possible in “Lookup Relationship”
Note: In MDR the master record i.e the owner of the primary record will become the owner the child record another feature that to be considered in the MDR, where it is not available in Lookup Relationship.
Below is the example for the primary and secondary records relations, in which the “Owner” of the “Company Object” becomes the Owner of the “Employees Object”. So, the Owner field is not visible in the assigned company employee record details.
Lookup Relationship Vs Master-Detail Relationship:
- 25 to 40 lookup fields are allowed per Object.
- The fields are not mandatory.
- If the parent is deleted the child is not affected.
- The Object has an owner field.
- The child has independent sharing & security.
- It does not allow rollup summary fields.
Master Detail Fields:
- 2 master detail fields allowed per object.
- The fields are always mandatory.
- The Object does not have an owner field.
- If the parent is deleted the child records are also deleted.
- The child inherits all the security and sharing from parent.
- It allows roll-up summary fields.
Few Points About Master-detail Relationship:
- The relationship is used when we need to connect 2 objects together in strong bonding mode.
- The dependency is mentioned in such a way that, the primary record controls the secondary record.
- If the primary record is deleted, the secondary records also delete, hence it is called as “Cascading Delete”.
- It gives rollup summary which helps to get a summary of child records.
What is Roll-Up Summary.
A roll-up summary determines the values of the related records, whereas in a related list. We can create a roll-up summary to display values of the master record based on field values in the detailed record, and the record must be related to MDR.
How to create Roll-Up Summary?
Let us create a RUS field in the desired “Company” from the list and observe the process.
Click on the “Company Names Object” >> Click on the quick access menu located on the right side of the application area(Org) >> New Field.
Step 1: Select the “Roll-Up Summary” >> Proceed to the next step.
Step 2: Enter the details of the field name. (Eg. Maximum Experience) >> proceed to the next step.
Step 3: select the summarised object. (Eg. Employees) >> Select the Roll Up type. (Eg. Max) >> select the field to aggregate. (Eg. Experience) >> Filter Criteria (Eg. All records) >> Proceed to next step.
Note: In filter criteria, the other option is used for filtering based on operator and values.
Step 4: In this step select who all can visualize the RUS field. >> proceed to next step.
Step 5: In this step the default selection of “Add the Page layout” >> proceed to Save button.
The Roll-Up Summary field in the “Company Names” displays the highest experience number in the “Maximum Experience” field in the “Company Names” object.
What is Reparenting?
Reparenting allows you to edit the parent details of the Object, which is not allowed to edit.(Eg.Employee).
How to create Reparenting?
Click on the “Employee” Object edit >> Custom fields and relationships >> Edit >> master-Detail Options >> Allow Reparenting >> Save.
After Save Go to Employees Object >> Select Employee >> Edit >> Option to select Company Name.
In the next topics, we will discuss in detail about “Salesforce Security”. Keep following us for more info on Salesforce Administration.
Mindmajix offers different Salesforce certification training according to your desire with hands-on experience on Salesforce concepts