[SalesForce] How prevent deletion in Event delete trigger and update a field instead

Our Salesforce users are deleting Events from Salesforce due to our integration with Outlook. When a Meeting from Outlook is deleted, we want the corresponding Event record in Salesforce to be not deleted but change the status field (a custom field on Activity) to be marked as "Cancelled" instead.
Is it possible to not delete the Event from delete trigger?

Best Answer

You cannot convert the delete event into an update. Once the DML operation has been started, you can block it (and potentially roll back the transaction) by adding an error on the record. That's unlikely to be what you want to do here.

Instead, I'd suggest you build your delete trigger to create a new Event (or Task), copying fields from the deleted recording and applying the transformation you mention to mark the event as cancelled. You can insert new Event records from the delete trigger.

Related Topic