Is there any admin setting in salesforce where child records are automatically deleted when the parent record is deleted when it is a lookup relationship?
2 Answers
You can use Cascade Delete Feature.
Cascade Delete Feature Provides Lookup Relationships the same cascading delete functionality previously only available to Master Detail Relationships
However, be careful with it:
Cascade delete, while useful for intentional deletions, increases the number of items that can be accidentally deleted without an admin noticing. In cases of accidental deletion, admins may miss the associated deletion of any child or grandchild objects, making it difficult to identify exactly which data was lost.
Resources:
By using cascade-delete
option you can able to delete the child records for lookup relationship and you need to contact salesforce support to enable cascade-delete
feature.
Delete this record also Available only if a custom object contains the lookup relationship, not if it’s contained by a standard object. However, the lookup object can be either standard or custom. Choose when the lookup field and its associated record are tightly coupled and you want to completely delete related data.
WARNING Choosing Delete this record also can result in a cascade-delete. A 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 to get the cascade-delete option enabled for your organization. Cascade-delete and its related options aren’t available for lookup relationships to business hours, network, lead, price book, product, or user objects.
Refer the Considerations for Relationships
Refer Enable 'cascade delete on custom lookup relationships' feature