Overview
When archiving data in Salesforce, maintaining the relationship between parent and child objects is crucial to preserve data integrity. The cascadeDelete attribute on relationship fields controls how deletions (and by extension, archiving) propagate from parent to child records. Based on this behavior, child objects are categorized into three types:
1. Mandatory Child Objects2. Optional Child Objects
3. Optional-Mandatory Child Objects
1. Mandatory Child Objects
Definition:
Directly related to the root object with cascadeDelete = true. These are automatically deleted when the parent is deleted. Their own descendants with cascadeDelete = true are also mandatory.
Archival Handling:
Automatically included in the archival process with the root object.
Example:
If Account is the root and Contact has cascadeDelete = true, then Contact is a mandatory child. Deleting the Account will delete the related Contacts.
2. Optional Child Objects
Definition:
Related via a field with cascadeDelete = false. These are not automatically deleted with the parent. Descendants of any object in this chain with cascadeDelete = false are also optional.
Archival Handling:
Not archived by default. Must be manually selected by the user.
Example:
Opportunity related to Account with cascadeDelete = false is an optional child. A Meeting related to Opportunity with cascadeDelete = false is also optional. Deleting the Account does not remove them.
3. Optional-Mandatory Child Objects
Definition:
Child of an optional object with cascadeDelete = true. Though the parent is optional, these children are deleted when the optional parent is deleted.
Archival Handling:
Automatically included when the optional parent is selected for archival.
Example:
If Opportunity (optional) has a child Task with cascadeDelete = true, then Task is optional-mandatory. Selecting Opportunity for archival also includes Task.