Does delete prevention on an association prevents a before delete activity on an object being executed?

7
I would like to delete an object. This object has delete prevention so that when there are still objects associated to it, it cannot be deleted. I also have a before delete activity on this particular object. When I delete this object and delete prevention prevents me to delete it, is the before delete activity then executed?
asked
2 answers
6

Short answer: no. Long answer: noooooooooo. The delete prevention check is performed first and only if it succeeds the before delete actions are run. In your case the check would fail and nothing would happen.

answered
5

Actually, before delete actions are executed before the delete prevention check is executed as this check is part of the actual delete action. However, as the delete prevention check throws an exception all changes in the current transaction are rolled back.

This means if you are executing the mentioned delete action in a microflow (without having created another Context object which started a separate transaction) all attempted database changes performed in before delete actions are reverted.

answered