You need to sign in to do that
Don't have an account?
Axel Duhême
Delete Trigger: Update records instead of Deleting them
Hi,
I'm trying to set up a trigger so that when a user deletes a contact, it is updated (with a True value in the Inactive__c checkbox) instead of being deleted.
The use case here is that when a user deletes a contact from their Outlook address book, I want it to remain in the database as inactive after Salesforce for Outlook / Lightning Sync triggers the delete.
Of course, I would include an excpetion in the trigger sor that User with the admin profile can properly delete records.
Hope someone can help!
Axel.
I'm trying to set up a trigger so that when a user deletes a contact, it is updated (with a True value in the Inactive__c checkbox) instead of being deleted.
The use case here is that when a user deletes a contact from their Outlook address book, I want it to remain in the database as inactive after Salesforce for Outlook / Lightning Sync triggers the delete.
Of course, I would include an excpetion in the trigger sor that User with the admin profile can properly delete records.
Hope someone can help!
Axel.
The algorithm is a bit weird but it works in my DE org.
The records get actually deleted , but the trigger undeletes them , and finally updates them with the flag.
Notice I had to use a @future method, because if you run all that synchronously, you stay in the original transaction and SF tells you that you cannot undelete a record that was just deleted
APex Trigger
Apex Class