Trigger a Flow to Run Before a Record Is Deleted
Where: This change applies to Lightning Experience and Salesforce Classic in Essentials, Professional, Enterprise, Performance, Unlimited, and Developer editions.
Who: To activate a record-triggered flow that runs before the record is deleted, you need the Manage Flows and View All Data permissions.
Why: For example, suppose that your Salesforce org has a custom field on the Account object that tracks the total items related to that account. Without automation, this field is updated manually every time a related item is deleted. Now, you can automate this task with a record-triggered flow that runs before a record is deleted.
The flow runs anytime an item is deleted. It finds the related account, and decrements the total number of items. When the flow finishes, the item that launched the flow is deleted.
How: When creating a flow, select Record-Triggered Flow.
To configure the flow to run before a record is deleted, click Edit on the Start element.
Select A record is deleted and you’re ready to build the flow.
The flow can access any record and perform actions before the record that launched the flow is deleted from the database. The $Record global variable contains the Salesforce record that launches the flow.
- Launching a flow after restoring a record via the undelete operation is not supported.
- Displaying custom error messages via the addError() method is not supported in invocable actions.