 Hello friends. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to demonstrate you how you can convert lookup relationship into master detail relationship. If you want to follow Salesforce training videos, you can search my name Sanjay Gupta on YouTube and you can follow my YouTube channel. Now coming on to the topic. So I have created a lookup relationship in my previous video. In that relationship, I included two objects, student and book. So I created lookup relationship on book and that was linked into student. Now I'm going to convert this lookup relationship into master detail. So first I'm going to open object manager and searching for the book object because lookup field is created on the book object. So if I scroll down, you can see here the student lookup is created here. So now we need to convert this into master detail relationship. Before that I am going to open my university app. So here you can see student and book both apps are available. So if I open book and click on all. So you can see three records are available here. So if we have existing records and we want to convert lookup relationship into master detail relationship. Then you need to make sure that all the lookup fields on each record, like here a student is populated. So it is not blank. If I open another one. So here you will see it is not populated. So this is blank. So now if we try to convert this lookup relationship into master detail relationship. So we will face an error because in case of master detail relationship, the field should be populated because it is mandatory. So let's try to convert and then we'll see what error comes and then we will resolve it. And if you if you have already populated all the lookups, then that error will not occur. Right, so in in two cases that error will not be coming in the first cases if you don't have any record. Second one is if you have records and the lookup field is populated on each record. In these two cases error will not come but in our case we have record but lookup field is not populated on each of the record. So now if I try to convert the type into master detail relationship. So you will notice that it will show an error. So it is asking for the label and name and other things what you want to change. So you can select as per the requirement. So like lookup filters, sharing setting allow re parenting. So these details are related to master detail relationship. So if you want to change you can then I'm clicking on next. So in case of master detail that field will be visible in form of editable mode on all the records on each profile. Because in case of master detail you need to populate that value that is mandatory. Now I'm clicking on save. So here you can see the error message is available. So you can read it. You cannot create a mass new master detail relationship on an existing custom objective records already exist. Right. You must create 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. So we need to populate all the lookup fields. Then we can convert this relationship. So let me populate this. So I think now we have all the records populated lookup field. So now if we try same thing again putting on change field type. Selecting master detail clicking on next and clicking on save. So this time you will not face that error and you will see your lookup is converted into master. Here it is and all on the records you will notice that a required indication will be available. Because in case of master detail you need to populate that field. So right now it is required. So if we try to create new book record then that mark will be available. Yeah. Here it is. You can see that stress. So it is indicating that the student is required. So you need to populate it and then you can save the record without populating this you cannot create the record. So I think you understood how we can convert lookup into master detail. So there are three scenarios. First is if you don't have any record then lookup will be converted into master detail normally. If you have records existing reports and all the lookups are populated in each record then also your lookup will be converted into master detail normally. In third case if you have records but lookup field is not populated on all the records then error will come. So you need to first populate them then you can convert lookup into master detail. So I hope you understood how we can convert lookup into master detail and what are the scenarios. If you want to follow salesforce training videos you can search me on YouTube and follow my channel. Thank you for watching this video.