 Hello friends, I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to demonstrate you how we can convert lookup relationship into master detail relationship. Before starting, let me share you how you can search Salesforce related CDs. You can search my name on YouTube so that you can find out Salesforce related videos. So here I have two objects. First is student. Here you can see I don't have any record. So first I'm going to convert a lookup that is available on student object into master detail. Then I will convert a lookup that is available on employee into master detail. So on employee I have two records, but on student I don't have any record. So let me share you first scenario. So I'm opening student object. In such student object I have one field that is lookup relationship field. So I'm clicking on edit and clicking on change field type. Then I need to select master detail relationship and I'm clicking on next. Then if you want to change some settings you can click on next otherwise you can directly save this. So this way we simply converted our lookup relationship into master detail relationship. So it is quite easy if you don't have any record in the object. Now what happens if we have records in the object? So I'm searching for the employee object. Inside employee object I have a field that is lookup relationship to opportunity. I'm clicking on edit, clicking on change field type, selecting master detail relationship, clicking on next. And clicking on save. So you will see an error message will be displayed. So it says you cannot create a new master detail relationship on an existing custom object if records already exist. So now I hope you understood how why I demonstrated this for two different objects. So further it says you must first create a lookup relationship, populate the lookup field with data in all records and then change the relationship type to master detail. Right. So it says you need to populate the data. So for this zero nine record, you can see this opportunity is blank. So that's why it is giving an error because if we convert lookup into master detail then master detail is a required field. So it should contain a particular value. So first we need to fill all the lookups or all the records here it is already available. So only one record was not having a lookup value field. So right now these two records are having values available in the lookup field. So now we can convert it into master detail relationship. So if you have records then you just need to fill all the values in the lookup fields then only you can convert it into master detail. So now if I convert this lookup into master detail. So here you can see this lookup is converted into master detail now. So this way you can convert your lookup field into master detail relationship. So it will be a good practice if you create appropriate lookup or master detail in the beginning because after having records it is difficult to change the data type from lookup to master detail or master detail to lookup. So keep this thing in mind while implementing these two relationships in the projects. I hope you understood how we can convert lookup into master detail relationship. If you want to watch more Salesforce related videos you can search me on YouTube by my name. Thank you for watching this video.