function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhijeet Purohit01Abhijeet Purohit01 

converting a look up field to master-detail field type.

How to convert a look up field to master-detail field type?

There are some records in the object. I am getting this error msg:

populate the lookup field with data in all records and then change the relationship type to Master-Detail.

 

 

How to populate the lookup field with data in all records?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
nickwick76nickwick76

When you are using master-detail you are required to have a lookup, but not for lookup fields. 

The best way is probably to export all records. Populate them with the right reference and then update the records back in.

 

HTH / Niklas

All Answers

nickwick76nickwick76

When you are using master-detail you are required to have a lookup, but not for lookup fields. 

The best way is probably to export all records. Populate them with the right reference and then update the records back in.

 

HTH / Niklas

This was selected as the best answer
Ankit AroraAnkit Arora

Nick is right, you need to fill the data first to convert lookup into mast-detail as mast-detail field is required. You can fill the dummy data in rest of the lookup fields so later you know which values are dummy and you can change it according to your need.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Abhijeet Purohit01Abhijeet Purohit01

Thanks for the reply.

I have understood what to do but I don't know how to do.

 

What if there are some 1000s records and I am trying to convert the lookup field to Master-Detail field?

Do I need to enter some dummy value for the LookUp field in all the records and then try converting it into Master-Detail field?

 

 

nickwick76nickwick76

Exactly!

So either you populate them with a dummy value just to be able to convert to a master-detail relationship or you add the right value from the beginning. If you are converting to master-detail there is probably a reason for that and then it should be important that it is connected to the right master.

 

So if you use data loader for example and export the ones out that need to be changed. Then you can do the modification in excel and the update back. 

 

But to answer your question. Yes, you need to populate every record before converting.

 

// Niklas