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
Geoff SpozettaGeoff Spozetta 

Master-Detail Populating Field with Data


I'm trying to create a new Master Detail Relationship between two objects, however I'm recieving this error message:

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. 

Which seems pretty straight forward, except I'm not sure how to populate the lookup field with the data. Can someone point me in thr right direction?
Ray C. KaoRay C. Kao
How many records do you have? If the number is not huge, you can just open those child object records and fill in the lookup field. But, if the number is huge, please consider to use import tool like Data Loader to fill in those child object records.
Following is the text from SF Trailhead page about Inter-Object Relationship
"You can convert a lookup relationship to a master-detail relationship, but only if the lookup field in all records contains a value."

It seems that you already had a lookup filed between two objects and many of its records were created without lookup field value, and thus no relationship can be established between records of these two objects.

You've got only two choices:
i) Fill all those lookup fields with correct values. (As random entries will have repurcussions in the future).
ii) If you can't fill these empty lookup field, then you have to delete these unrelated records.

But, if you don't wanna go with either of these choices, what you can do as a workaround is:
To create a dummy record in Object1 (which is going to be Master) and populate its Id in all empty lookup fields in Object2 (which is going to be child).
This is will solve you problem and moreover anytime in future, you will know -> these records were those records for whom relationship could not be established.
(A small temporary trigger will do that for you)

In case this helps solve you problem, Mark it as Best Answer.