By continuing to navigate on this website, you accept the use of cookies to serve you more relevant services & content.
For more information and to change the setting of cookies on your computer, please read our Cookie Policy.

How to create Master-detail relationship in Salesforce?

Master-detail relationship is like parent-child relationship where, master represents a parent and detail represents a child in which master object controls some behaviors of the detail object. Like whenever a Master object record is deleted then the detail object related to it also gets deleted.

Master-detail relationship can be defined between custom objects or between a standard object and a custom object. The detail object automatically gets the security and sharing settings given to the master object.

A child of one master detail relationship can't become a parent of another object. To relate an object to another object, no records should exist in the child object.

Rollup summary fields can only be created on Master records, which are used to calculate the sum, avg, min etc. of child records.

How to create a Master-detail relationship:

  • In Setup, go to objects and select the custom object you want to create master detail relationship.
  • In the selected custom object, click on new in the custom fields and relationships list.
  • Select Master-detail relationship and click on next where you will get a pick list to select the other object which you want to relate. Click on next after selecting another object.
  • Enter field name, description, sharing setting, reparenting options and click on next.
  • Establish field-level security, add the reference field to page layout, add custom-related lists and click on save.

We can't create a Master-detail relationship on existing records. To do that, we have to create a lookup relationship for that record and then convert it into master detail.

To convert a lookup relationship to a master detail the existing record should consist of valid lookup field values.

You can build many to many relationships using two master detail relationships in an object, and it is called as Junction object.

Standard objects can't be on a detail side of a master detail relationship. Access to detail is determined by the access given for master.

Limitations:

  • Only up to two master detail relationships are allowed for an object.
  • You can have only Upto three levels of custom detail levels. 
  • We can't create a Master-detail relationship when the custom object already contains data.
  • Each object is allowed to have one or two masters or up to 8 details.
  • After converting a lookup field into Master-detail relationship, test your custom reports, whether they are usable or not. Sometimes upon converting, the custom reports can become unusable due to different standard report types.
    Posted On
  • 22 December 2017
  • By
  • Micropyramid

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Packages in salesforce

In the salesforce organization, when you are building a component or application, it's important to know how the component or application should be distributed to ...

Continue Reading...
How to use list methods in salesforce

Apex provides collections such as List, Set, Map. These are similar to arrays, but these collections have advanced features and easier methods than an array. ...

Continue Reading...
Approval process in Salesforce

As we know there will be role hierarchy in many organizations and permissions are assigned according to their roles. So, When a record or data ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties