• #9982
    Salesforce | Ajit Ajit #238

    Not able to create a Master Detail field in Salesforce. Need assistance.

    I have 2 objects obj1 and obj2. obj1 has some records and on obj2 I was creating a master detail relationship field to obj1 but it is throwing error that we can’t create master detail relationship on the existing object having records so create the field as lookup an populate the records then change the field type of the field, so I did that but this also did not solve my problem. Please help me out on this.

    Tagged: , , , , ,

    • This topic was modified 2 years, 3 months ago by Salesforce | Ajit Ajit.
    • This topic was modified 2 years ago by Salesforce | Team Team.
    • This topic was modified 5 months ago by Salesforce | Team Team.
    • This topic was modified 5 months ago by Salesforce | Team Team.
    Salesforce | Naman Naman #125

    Make sure that both of the objects having no records before creating master detail.

    Salesforce | PRANAV PRANAV #2


    Salesforce will not accommodate a master detail relationship to a custom object that already contains data.

    This is because creating a master detail relationship adds a new required field to the custom object (known as a “foreign key” to database administrators). Each data record in the object needs to have a valid value in the field — it cannot be left blank.

    • If the object ( detail ), that you want to relate to, does not yet have many records, a possible workaround is to delete the data in your custom object, and then add the master-detail relationship.
    • If you don’t want to lose all of your existing data, another approach is as follows:
      1. Create a Lookup relationship instead of a Master-Detail relationship. This adds the new “foreign key” field to the custom object, but it is not required to have a value for each data record. Do NOT make the Lookup “required”.
      2. Add a valid value in the lookup (foreign key) field of each data record in the custom detail object. (You may need to create a custom tab to facilitate this data entry.)
      3. Edit the object relationship and change the relationship type from Lookup to Master-Detail.

    Hope this helps you more.

Viewing 3 posts - 1 through 3 (of 3 total)

Please to reply to this topic.


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?