Activity Forums Salesforce® Discussions Can we create field in custom object containing some records with master detail relationship in Salesforce?

  • shariq

    Member
    September 29, 2018 at 9:26 am

    No, directly we cannot create master-detail relationship if custom object contains existing records.
    Following are the steps to create master-detail relationship when records are available in custom object.

    First create field with lookup relationship.

    And then associate look field with parent record for every record.

    Next change the data type of the field from look up to Master detail.

  • Aman

    Member
    September 29, 2018 at 6:44 pm

    Hi

    Read these steps:

    To create the master-detail relationship field to relate custom object with the account  objectFrom Setup, enter Objects in the Quick Find box, then select custom object
    Click Review.
    In the Custom Fields & Relationships related list, click New.
    Select Master-Detail Relationship, and click Next.
    In the Related To drop-down list, choose account, and click Next.
    Click in the Field Name text box and enter the field name —-.
    Select the Read/Write radio button.
    Check Child records can be reparented to other parent records after they are created if you want to be able to change the relationship field’s value. If you leave this box unchecked, you can’t change the value in the future.
    Click Next.
    Accept the defaults in the remaining three steps of the wizard.
    Click Save.

    Thanks

  • Avnish Yadav

    Member
    September 29, 2018 at 9:26 pm

    Hello,

    You need to create the lookup, then populate each one so that each child record has a parent record. This is because a master-detail relationship does not allow for ‘orphaned’ child records. Once you have a lookup with each child having a parent, then you can go back and convert the lookup field to a master-detail.

    But Remember,

    Maximum number of Master-Detail relationships on a Custom Object is: 2
    Maximum number of Lookup relationships on a Custom Object is: 25
    Maximum number of Lookup relationships on a Standard Object is: 25

    Thanks.

  • Parul

    Member
    September 30, 2018 at 8:00 pm

    Not possible to create the MD relationship, First create as a lookup then populate each record as a parent then convert into master detail.

  • Pooja

    Member
    February 17, 2020 at 2:48 pm

    No, We can not create a field in custom object containing some records with master detail relationship in Salesforce.

  • Pooja

    Member
    February 28, 2020 at 2:13 pm

    Yes,We Can  create field in custom object containing some records with master detail relationship in Salesforce

  • Aditya

    Member
    February 28, 2020 at 2:47 pm

    Hi,

    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).

Log In to reply.

Popular Salesforce Blogs