In Extending Custom Objects and Applications, we will learn about the use of relationship types when building custom objects. This section will cover 8% of total score in Salesforce Advanced Administrator exam. Without further ado, let's get to the topic!
NOTE: This post is written in April 2019 and content might be changed/updated overtime. The content is inspired by focusonforce.com.
Relationship Types
- Relationships are used to relate different objects and it can created between standard and custom objects.
- External object relationships support linking Salesforce object with external objects.
Lookup Relationships
- Allow one object to be related to another in one-to-many relationship.
- A lookup relationship that lookup iteself is called self-relationship. For example, a field in
Contact
that lookupsContact
. Standard Report Types
are automatically created for each lookup relationship.- Lookup field can be cleared when the lookup record is deleted, or don't allow the deletion of lookup record, or delete the record also.
- If a parent record is deleted, field tracking history for the child record does not record the deletion.
Hierarchical Lookup Relationships
- Only available for
User
object, allowing oneUser
to be related to another.
External Lookup Relationships
- External lookup relationship is used to link a child standard, custom or external object to a parent external object.
- The standard External ID field on the parent external object is matched against the values of the child's external lookup relationship field.
- External object field values come from an external data source.
Indirect Lookup Relationships
- Indirect lookup relationship is used to link a child external object to a parent standard or custom object.
- The parent object field and the child object field are specified to match and associate records in the relationship.
- A custom unique External ID field on the parent object is selected to match against the child's indirect lookup relationship field. Whose values come from an external data source.
- NOTE: this is a feature of
Salesforce Connect
.
Master-Detail Relationships
- Master-detail relationship is used to relate one object to another in a one-to-many relationship (like lookup relationship).
- Difference between lookup and master-detail relationship:
- Detail record cannot exist without its master record.
- When a master record is deleted, all of the detail records are deleted as well.
Roll-up
summary field (sum, max, min, count) is only available on the master record.
- Something about master-detail relationship:
User
andLead
do not have master-detail relationship.- The master-detail relationship is required to be on the page layout of detail and subdetail records.
- The master object can be standard or custom object, but the detail object cannot be a standard object.
- When a master record is undeleted, the detail and subdetail records are undeleted as well.
- Custom objects on detail side cannot have their own sharing rules, manual sharing or queues.
- Detail and subdetail records inherit the security settings and permissions from master record.
- Detail records can be reparented to other parent records after they are created.
Converting Relationships
- Master-detail relationship cannot be converted to lookup relationship if there is roll-up summary field on the master object.
- A lookup relationship cannot be converted to master-detail relationship if the lookup field in all records does not contain a value.
Many-to-Many Relationships
- Many-to-Many Relationships allows two objects to be related to each other such that a record of one object can be linked to multiple records of another object and vice versa.
- A
Junction Object
is a custom object with two master-detail relationships to two different record types.
Well, this is a relatively short topic. I will update the content as time goes by. That's for now! See you in the post!
Post was published on , last updated on .
Like the content? Support the author by paypal.me!