Today, I got an interesting requirement on the Account Deletion. we all know that when we delete a account, all the records that are associated with it will delete as it is defined in Relation Behaivour. “Delete – Cascade all” and we cannot even change the configuration.
After some search we got to know the power of Pre-Validation step. we have written a plugin and registered on the PreValidation step. Written a logic to loop through the contacts that are associated with the deleting account and updated ParentAccount lookup of the contacts with null.
Hope this helps.