imported>Aeric |
imported>Aeric |
Line 1: |
Line 1: |
| {{Deprecated|<br>This choice used to be an option when specifying creating a Lookup field. The option has become redundant however, and has been removed. Now, [[Rollup Summary Fields]] and [[Subforms]] can be used for summary calculations on fields in detail records, and [[Cascade Rules]] can automatically delete those records when a master record is deleted. Those operations work across multiple related objects--not just those that have a particular flag set on the Lookup field that connects them.)}}
| |
|
| |
| ==About Master-Detail Relationships== | | ==About Master-Detail Relationships== |
| A Master-Detail relationship is an association between two objects. When a Master-Detail relationship is created, it implies a tight relationship between the two objects. In essence, a Master-Detail relationship ''locks'' the objects together, so that every record in a Detail Object is associated with a record in a Master Object. | | A Master-Detail relationship is an association between two objects. When a Master-Detail relationship is created, it implies a tight relationship between the two objects. In essence, a Master-Detail relationship ''locks'' the objects together, so that every record in a Detail Object is associated with a record in a Master Object. |
Line 15: |
Line 13: |
| If an order is deleted, then all associated line items are deleted as well. Β | | If an order is deleted, then all associated line items are deleted as well. Β |
|
| |
|
| ==Configuration==
| | {{Note|The option to specify "Master-Detail relationship" when creating a Lookup field became redundant, and has been removed. Now, [[Rollup Summary Fields]] are used for summary calculations on fields in detail records, and [[Cascade Rules]] can be used automatically delete detail records when a master record is deleted. Those operations work across multiple related objects--not just those that have a particular flag set on the Lookup field that connects them.)}} |
| To create a Master-Detail relationship:
| |
| #Click '''[[File:GearIcon.png]] > Customization > Objects > {object} > Fields'''
| |
| #Choose one of the following options:
| |
| ::'''Edit an existing [[Lookup]] field''', and click the '''Master-Detail Relationship Enabled''' checkbox
| |
| ::The platform then verifies that the Master-Detail relationship can be Enabled:
| |
| :::*If every record in the Detail object has an associated value for the lookup, then create the Master-Detail relationship
| |
| :::*If any record in the Detail object does not have an associated value for the lookup, then:
| |
| ::::#Do not create theΒ Master-Detail relationship
| |
| ::::#Notify the user that the Detail object contains existing records
| |
| ::::#Ask the user to build the associations by selecting a value for each Lookup field in the Detail object
| |
| :::::*After this is completed, the user edit the [[Lookup]] field, and click the [Master-Detail Relationship Enabled] checkbox
| |
| ::'''Add a new [[Lookup]] field''', and click the [Master-Detail Relationship Enabled] checkbox
| |
| ::The platform verifies that the Master-Detail relationship can be Enabled:
| |
| :::*If the Detail object is empty (contains no records), then create the Master-Detail relationship
| |
| :::*If the Detail object is not empty (contains one or more records), then:
| |
| ::::#Do not create theΒ Master-Detail relationship
| |
| ::::#Notify the user that the Detail object contains existing records
| |
| ::::#Ask the user to build the associations by selecting a value for each Lookup field in the Detail object
| |
| :::::*After this is completed, the user can edit the [[Lookup]] field, and click the [Master-Detail Relationship Enabled] checkbox
| |
| Β | |
| Β | |
| To disable a Master-Detail relationship:
| |
| Β | |
| If no [[Rollup Summary Fields]] exist, the Master-Detail relationship can be disabled, as follows:
| |
| #Click '''[[File:GearIcon.png]] > Customization > Objects > {object} > Fields'''
| |
| #*Edit an existing [[Lookup]] field
| |
| #Uncheck the [Master-Detail Relationship Enabled] checkbox
| |
| Β | |
| ==Considerations==
| |
| Β | |
| ===Requirements and Restrictions===
| |
| *The Master-Detail relationship option can be enabled on a [[Lookup]] field in a {{type| }}
| |
| :*{{Type}}s are not eligible
| |
| *An Object can be a Master in no more than one Master-Detail relationship. (For more complex requirements, use the [[Composite Object]] APIs.)
| |
| *When a Master-Detail relationship is created, all records added to the Detail object will have a relationship to the Master object
| |
| *An index is automatically created in a Master-Detail relationship; this index is associated with the Detail object
| |
| *When adding a record to a Detail object, the Lookup field is ''Required''
| |
| :*When updating a record in a Detail object, the Lookup field is ''Read-Only''
| |
| *If a [[Rollup Summary Field]] (based on a Lookup field in a Master-Detail relationship) exists, then the Master-Detail relationship option in the Lookup field cannot be disabled
| |
| *If a Master-Detail relationship is enabled, the Lookup field in the Detail object cannot be changed to point to a different object
| |
| <!-- this is true for ordinary Lookup fields as well-->
| |
| *A Detail object cannot also be a Master object
| |
| *[[Self Reference Lookup]]s cannot be converted to Master-Detail relationships
| |
| *If two objects have a Parent-Child relationship (via [[Object Inheritance]]), these objects are not eligible for a Master-Detail relationship
| |
| *Multiple Master-Detail relationships for a pair of objects is not allowed
| |
| *If a Lookup field in a Detail object is deleted, then the Detail object index is also deleted
| |
| :*The Index created automatically via enabling the Master-Detail relationship should not be deleted by the user
| |
| *A Master-Detail relationship can be disabled if no [[Rollup Summary Fields]] exist
| |
| :*If the Master-Detail relationship option in a Lookup field is disabled, then the associated Index is also deleted
| |
| Β | |
| ===Permissions===
| |
| *Object-level access for Detail objects are controlled by [[Record Access Permissions]]
| |
| Β | |
| ===Rollup Summary Fields===
| |
| *If a Rollup Summary Field exists based on Master-Detail relationship, then the Master-Detail relationship cannot be disabled for that Lookup field
| |
| <!--
| |
| ===Multiple Record Ownership==
| |
| *Records in the Master object can have [[Multiple Record Owners]]
| |
| *Multiple record owners cannot be enabled for records in the Detail object
| |
| *Record ownership is hierarchical; the Master object [[Record Owner]] is the Record owner of the records in the Detail object
| |
| *[[Custom Access Criteria]] apply for Master and Detail objects
| |
| *The [[Merge Records]] option is not available
| |
| -->
| |
| ===Record-level Actions===
| |
| ;Record Ownership:
| |
| *The [[Record Owner]] of Master object defines the ownership of the Detail object
| |
| *:All of the Role-based [[Validations]] and [[Team Data Sharing Policies]] are tied to the role of the master record owner
| |
| *If a Master-Detail relationship is disabled, then record ownership of records in the Detail object reverts back to the user who created the original record
| |
| *Update/View/Delete actions on a record in the Detail object are defined by the [[Record Owner]] of record in the Master object
| |
| *: The owner of the record in the Master object receives all notifications (email notifications to the record owner, task ownership, record ownership changes, etc.)
| |
| Β | |
| ;Restoring Deleted Records:
| |
| *If the Master object is restored, then all associated Detail records are restored
| |
| :*If a Master object is deleted forever, then no records can be restored from the Master or the Detail object
| |
| *If record(s) in a Detail object are deleted, and the Master object is restored, then the record(s) in the Detail object are not restored
| |
| Β | |
| === Object Deletion ===
| |
| *A Master object cannot be deleted unless all records in the Detail object are deleted
| |
| Β | |
| === Data Import / Export ===
| |
| ;Data Import:
| |
| :*Records can be imported into the Detail Object of of a Master-Detail relationship.
| |
| ::''Learn more: [[Manage_Data_Import#Detail_records_in_a_Master-Detail_relationship|Detail records in a Master-Detail relationship]]''
| |
| ;Data Export:
| |
| :*Export the Detail object to capture all information in the Master-Detail relationship
| |
| ::*The actual [[Record Owner]] of the Detail object is exported (not the Record Owner associated with the Master object)
| |
| Β | |
| ===Views/Reports/Search===
| |
| *In Views/Reports/Search/Filter actions on records in Detail objects, the [[Record Owner]] is the owner of the Master object (<tt>owner_id</tt>)
| |
| Β | |
| Β | |
| ===Packaging===
| |
| {{:Packaging Objects in a Master-Detail relationship}}
| |
| Β | |
| ===Inheritance===
| |
| *A Detail object can be a parent object in an [[Object Inheritance]] relationship; in this case, all children of the Detail object are consideredΒ to be children of the Master object
| |