In Salesforce, when we create the lookup relationship between the Objects, but later on, sometimes when we need characteristics like MDR, then we can convert the lookup relationship into a master-detail relationship.
In this Salesforce tutorial, we will learn to convert a Lookup to a Master-Detail in Salesforce. We will explore the Lookup Relationship and MDR (Master-Detail relationship), understanding why transformation is necessary.
Additionally, we will see how to convert the lookup relationship into a master-detail relationship in Salesforce.
Lookup Relationship in Salesforce
In Salesforce, when we want to access data from the parent object to the child object, a relationship is used. There are two types of Lookup Relationships: one-to-one and one-to-many.
It is recommended to establish a one-to-many lookup relationship. In this case, a lookup field is not required.
Master-Detail Relationship in Salesforce
The MDR field is required in the master-detail relationship because a child object cannot exist without the parent object. When we delete the parent record, the child record is automatically deleted in the master-detail relationship.
In the master-detail relationship, we can use the Rollup Summary field.
Why do we need to convert the lookup relationship into a master-detail relationship in Salesforce?
In the lookup relationship, we sometimes need to make the lookup field required. Additionally, we want to ensure that when parent records are deleted, the associated records are also automatically deleted. To fulfill this requirement, we convert the lookup into a master-detail relationship.
Important:
When converting the lookup into MDR, we should ensure the lookup field from the child object has an assigned parent value, meaning it cannot be blank.
Example- Convert Lookup into Master-Detail in Salesforce
Using the following steps, we can convert the lookup relationship into a master-detail Relationship.
1. Go to Setup. -> Object Manager. -> Search the object on which the Lookup relationship is present. -> Here, I have Custom Object Student_c.

2. Then click on the Fields and Relationships.
Next, locate the lookup relationship field you have already created and click on it. Here, I have selected the Faculty field.

3. When you click on the field, you will see the Edit button. When we click on the Edit button, we can make changes to that field.

4. Here, we want to change the relationship of that field, so there is an option to Change the Field Type; click on it. Using this option, we can change the Lookup into an MDR relationship.

5. You can see I clicked on the Master-Detail Relationship option to change Lookup to MDR. Then, I clicked on the Next button.

6. In this section, don’t change anything, then click on the Save button. If you have followed all the instructions that we discussed earlier, then this field will be saved. Otherwise, it will give an Error.

7. Here we have an Error. This is because we haven’t considered converting the relationship. Now, we will go back to the manager records to check if we have entered any blank lookup fields.

8. Now, we have one blank lookup field; we will assign it a value.

9. Now, all lookup fields have values so that we can proceed. Again, you need to follow the earlier steps to convert relationships.

10. After converting the relationship successfully, you will see the Faculty Field converted the lookup relationship into a master-detail relationship.

This is how we can convert the lookup relationship into the master-detail relationship in Salesforce.
Conclusion
I hope you have an idea about converting a lookup relationship into a master-detail relationship. In that, we have seen the lookup relationship and MDR(Master-Detail relationship), and why there is a need to convert the relationship. We have also seen how to resolve any errors.
You may like to read:
- Convert Master-Details Relationship into Lookup in Salesforce
- Salesforce External Lookup Relationship Data Type
- How to Create Master-Detail Relationship in Salesforce

Shubham is a Certified Salesforce Developer with technical skills for Building applications using custom objects, approval processes, validation rule salesforce flows, and UI customization. He is proficient in writing Apex classes, triggers, controllers, Apex Batches, and bulk load APIs. I am also familiar with Visualforce Pages and Lighting Web Components. Read more | LinkedIn Profile