How to Convert Lookup to Master-Detail in Salesforce

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 about converting a lookup relationship into a master-detail relationship. We will see the lookup relationship, MDR(Master-Detail relationship), and why it is necessary to convert.

Additionally, we will see how to convert the lookup relationship into a master-detail relationship in Salesforce Lightning and Salesforce Classic.

Lookup and Master-Detail Relationship in Salesforce

What is the 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 advised to create a lookup relationship with one-to-many sides in a lookup relationship. In this case, a lookup field is not required.

What is the 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.

Why do we need to convert the lookup relationship into the master-detail relationship in Salesforce?

In the lookup relationship, sometimes we need to make the lookup field required and also want the when parent records get deleted, the records that associate with parents records get automatically deleted. To fulfill this requirement, we convert the lookup into the master-detail relationship.

See also  How to Set Visible Lines for Text Rich Field in Salesforce

Important:

While converting the lookup into MDR, we should consider that the lookup field from the child object should have an assigned parent value is required which means it should have some value, it should not be blank.

How to Convert Lookup into Master-Detail in Salesforce Lightning

Using the following steps, we can convert the lookup relationship into a master-detail Relationship.

1. First, log in to Salesforce Org. You will see the Home page. At the top of the screen, you can see the navigation bar. Click on the Object Manager tab. After clicking on Object Manager, all objects will be displayed on the screen.

In the search box, you can search for the object name on which you want to create the record type. Here, I have selected the Custom Student_c object.

Example of convert lookup relationship into master detail in Salesforce

2. After clicking on the selected object you will see on the left side some options will display, scroll down you will find the Fields and Relationships option. Click on it.

Then, find the lookup relationship field that you have already created and click on that. Here, I have selected the Faculty field.

Example of convert lookup relationship into master detail in Salesforce Lightning

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.

Convert lookup relationship into master detail relationship in Salesforce

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.

Convert lookup relationship into masted detail example in Salesforce

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

Need of converting lookup relationship into master detail in Salesforce

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.

How to convert lookup into MDR in Salesforce

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

Need of converting lookup relationship into master detail in Salesforce Lightning

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

Convert lookup relationship into masted detail example in Salesforce Lightning

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

How to convert lookup relationship into MDR in Salesforce Lightning

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

Converting lookup relationship into master detail in Salesforce.jpg

This is how we can convert the lookup relationship into the master-detail relationship in Salesforce.

See also  How to Delete Master-Detail Relationship in Salesforce

Conclusion

I hope you have got an idea about converting a lookup relationship into a master-detail relationship. In that, we have seen the lookup relationship, MDR(Master-Detail relationship), and why there is a need to convert the relationship. We have also seen If any error occurs how we can resolve it.

You may like to read: