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
pooja kesharwanipooja kesharwani 

Failed to create Master-Detail relationship between the objects

I have two objects, job and employee. I tried to relate them with Master Detail but I am getting the below error:

You cannot create a new Master-Detail relationship on an existing custom object if records already exist. 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.

Kindly help me here.
 
Best Answer chosen by pooja kesharwani
PriyaPriya (Salesforce Developers) 
Hi Pooja,

Does those objects have look up relationship?

If no, then follow the below steps :-
  1. 1. You must first create a Lookup relationship between the objects.
  2. 2.populate the lookup field with data in all records,
  3. 3.and then change the relationship type to Master-Detail.
Kindly mark it as the best answer if it works for you.

Thanks & Regards,
Priya Ranjan