I need to prevent deletion of our dummy account, which is part of the Lead conversion process under certain conditions. And it does prevent deletion. However, the error I am adding to the account record does not bubble up to the UI.
Am I doing something wrong or is this an expected behavior? Do I need to move my code to "isUpdate" and check the "IsDeleted" flag instead?
Code:
if (Trigger.isBefore) {
// Prevent dummy account deletion
if (Trigger.isDelete) {
for (Account a : Trigger.new) {
if (a.Name == 'DO NOT DELETE') a.addError('This account may not be deleted. It is part of the Lead conversion process.');
}
}
Actual error:
There's a problem saving this record. You might not have permission to edit it, or it might have been deleted or archived. Contact your administrator for help.