Question

Difficulty: HardObject Relationships (Lookup, Master-Detail, Many-to-Many)

An administrator at Universal Containers needs to track compliance audits. The company uses a custom object named Inspection_Site__c and a custom object named Audit_Report__c, which are currently connected by a Lookup relationship. Management introduces two new requirements:
1. Deleting an Inspection_Site__c record must automatically delete all associated Audit_Report__c records.
2. A field on Inspection_Site__c must continuously display the aggregate count of all related Audit_Report__c records.

When attempting to create a Roll-Up Summary field on Inspection_Site__c, the administrator discovers that the option is unavailable. Which sequence of actions should the administrator perform to satisfy these requirements?

  1. A
    Create a Roll-Up Summary field directly on Inspection_Site__c using the existing Lookup relationship, and enable the Cascade Delete option in the Lookup field definition.
  2. Populate the Inspection_Site__c lookup field on all existing Audit_Report__c records, convert the Lookup relationship to a Master-Detail relationship, and create the Roll-Up Summary field on Inspection_Site__c.Answer
  3. C
    Delete the existing Lookup relationship field on Audit_Report__c, create a new Master-Detail relationship field without populating parent references, and build the Roll-Up Summary field on Inspection_Site__c.
  4. D
    Change the Organization-Wide Default sharing setting of Audit_Report__c to Controlled by Parent to automatically enable Roll-Up Summary fields on the parent Inspection_Site__c object.

Answer

Ensure all existing Audit_Report__c records have a value in the Inspection_Site__c lookup field, convert the existing Lookup relationship field to a Master-Detail relationship, and then create the Roll-Up Summary field on Inspection_Site__c.
To fulfill the requirements, the relationship must be converted to Master-Detail because Master-Detail relationships automatically delete detail records when the master record is deleted and enable the creation of Roll-Up Summary fields on the master object. A Lookup relationship can only be converted to a Master-Detail relationship if all existing child records have a value in the lookup field.

Step-by-Step Solution

1
Audit existing records and populate parent values.
Every Audit_Report__c record contains a non-null reference to an Inspection_Site__c record.
Salesforce enforces that a Master-Detail relationship cannot be created or converted if child records exist without a parent assigned.
2
Convert the custom Lookup relationship field on Audit_Report__c to a Master-Detail relationship.
The relationship type changes to Master-Detail, enabling automatic cascade deletion of child records when a master record is deleted.
Master-Detail relationships inherently control deletion cascade behavior and security inheritance from master to detail.
3
Create the Roll-Up Summary field on Inspection_Site__c.
The Roll-Up Summary field option becomes available and active on Inspection_Site__c to count related Audit_Report__c records.
Roll-Up Summary fields are exclusively allowed on master objects targetting detail records in a Master-Detail relationship.

Key Concept

Converting Lookup Relationships to Master-Detail Relationships and Roll-Up Summary Requirements
Rate this question