How To Enable Cascade Delete On Custom Lookup Relationships Field
In this blog, you will learn to provide Lookup Relationships the same cascading delete functionality previously only available to Master-Detail Relationships.
Important Note:
- Cascade delete bypasses security and sharing settings, which means users can delete records when the target lookup record is deleted even if they don’t have access to the records. To prevent records from being accidentally deleted, cascade-delete is disabled by default. Contact Salesforce Support to get the Enables cascade delete on custom lookup relationships feature enabled for your organization.
- Cascade delete and its related options are not available for lookup relationships to Business Hours, Community, Lead, Price Book, Product, or User objects.
In a chain of lookup relationships, these behaviors work independently on each target field at each level:
For example, field A is the target lookup of field B, which is the target lookup of field C. You can have a delete restriction on A and none on B, which means that A can’t be deleted but B can. Once B is deleted, the relationship between A and B no longer exists and C will hold an empty value for the lookup.
In a multilevel lookup relationship, these options might conflict:
For example, in the scenario where field A is the target lookup of field B, which is the target lookup of field C, you might specify that A can delete B, but B can't be deleted because it’s in a relationship with C. If you try to delete A, you’ll get an error saying that B can’t be deleted because it’s linked to C.
Note on Field History Tracking:
If the parent record in a lookup relationship is deleted, the field history tracking for the child record does not record the deletion. For example, if a parent account is deleted, the Account History related list for the child account does not show the deletion.
To process the request, please have a System Administrator create a Support Case with Feature Activations & Limits Team.
Please also include the following:
I understand that the cascading deletion functionality bypasses security and sharing settings, which means users can delete records when the target lookup record is deleted even if they don’t have access to the records (YES/NO):
The feature can also be used in scenarios where the following error is encountered:
Delete Operation Too Large. You can’t delete more than 100,000 combined objects and child records at the same time. Select fewer records to delete. If you're trying to delete one object that has more than 100,000 child records, delete an appropriate number of child records before deleting the object.
Click here to return to the previous page.
DELETE_OPERATION_TOO_LARGE:Cascade deleting too many records.
Steps in Lightning :
1. Click on Setup
2. Object Manager
3. Select the Object the custom lookup field is created
4. Open the Lookup Field
5. Select the Edit Button
6. Put a tick mark on the option : "Delete this record also. This allows users to delete large numbers of records without regard for sharing or visibility constraints."
7. Hit Save.
Steps in Classic :
For Standard Objects with Custom Lookup Field :
1. Click on Setup
2. Look for the Object the lookup field is created
3. Click on Fields
4. Open the Lookup Field
5. Select the Edit Button
6. Put a tick mark on the option : "Delete this record also. This allows users to delete large numbers of records without regard for sharing or visibility constraints."
7. Hit Save.
For Custom Objects with Custom Lookup Field :
1. Click on Setup
2. Open Objects
3. Select the Object where the custom lookup field is created
4. Look for "Custom Fields & Relationship"
5. Open the Lookup Field
6. Select the Edit Button
7. Put a tick mark on the option : "Delete this record also. This allows users to delete large numbers of records without regard for sharing or visibility constraints."
8. Hit Save.
Follow Us