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
anandanandanandanand 

cannot create a new Master-Detail relationship

how to create a Master-Detail relationship field it shows 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.

Sunny GSunny G

Create a Junction Object with both the Object i.e. Master & Detail. Only then you will be able to create it.

CoryCowgillCoryCowgill

Master - Detail relationship requires that the Detail Record (Child) ALWAYS have a Master (Parent) record since the detail record inherits security and ownership from the parent record.

Therefore, if you want to create a Master - Detail relationship between existing objects, you need to make sure that all the existing records for the child object have a lookup value to the parent object BEFORE you can create the Master Detail relationship.

 

1. Create a lookup from the child object to the parent object.

2. Populate ALL the records with a valid lookup value to the parent.

3. Change the Lookup relationship to a Master - Detail relationship. This is only allowed if ALL RECORDS HAVE A VALID LOOKUP. Otherwise you'll get the error you describe.

 

The Master-Detail relationship is covered in detail in the Certification Exam and is in the Developer Guide (Chapter 3).

 

http://wiki.developerforce.com/index.php/Force_Platform_Developer_Guide

LinThawLinThaw
Hi,
How to populate ALL the records with a valid lookup value to the parent?
using dataloader or ?

Regards,
LinThaw.
Susan Harris 6Susan Harris 6
Hi LinThaw, If you haven't already found a way to do this, you can use Lookup Helper to automatically populate your lookup fields. You can install it free on the AppExchange: https://goo.gl/P9G7vA

Full disclosure, I work for Passage Technology - the makers of Lookup Helper.
LinThawLinThaw
Thanks Susan...
Krzysztof SiwkoKrzysztof Siwko

To solve the problem and create Contact__c and Property__c fields you need to delete all the records in the object tab fg. Offer Tab. After that you'll able to create those fields. Window with new offer will have contact and property fields.

If you don't want to delete all your offer entries then check that link: https://help.salesforce.com/articleView?id=000005186&type=1

 

Abhaysing BhosaleAbhaysing Bhosale

Hello ,
I am trying to create  Master Detail Relationship between Doctor and patient object but getting following message,

"Cannot Create Master-Detail Relationship
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." 

Please any one suggest me steps to reslove this..

Thanks,
Abhaysing Bhosale
LinThawLinThaw
Hi Abhaysing,
Answer is in the 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.

 
Abhaysing BhosaleAbhaysing Bhosale
Thanks Linthaw,
but actually i am new and  beginner in salseforce trying to learn. so didnt get how to create lookup relationship.. :(
 
Arundathy KrishnanArundathy Krishnan
I am getting the same error message as mentioned here before, while solving the below mentioned challenge on Unit 2 of Data Modelling. Can someone please help in understanding how to solve this challenge. 

"Challenge Requirements:
On the Offer object, add a Master-Detail relationship to the Property object named Property
On the Offer object, add a Lookup relationship to the Contact object named Contact
Arundathy KrishnanArundathy Krishnan
Hello, I think i posted the question here by mistake. M not sure if this was the right page to post the question.

However, I was able to find solution to the above challenge. So, for answer, please refer to the knowledge article - Unable to create master-detail relationship, in Help section of Trailblazer community. 
Felix DsouzaFelix Dsouza
Hello Arun - I wonder if you managed to get this sorted, however I am a learner too and I just about deleted all the records I had created from all the objects. Once done, I started the process all again and it worked. 
prerna mishra 2prerna mishra 2
I tried creating look up field first, then enter values for the field and then changing the field value back to master-detail. Does that mean direct master detail field relationship cannot be make? Always first the field should be look up and then once all values are entered field type is again changes to master detail. Is this the only way?