When a record is saved in Salesforce with an insert, update, or delete action, Sweep follows a specific order of execution. These events are managed differently depending on the type of action (insert, update, delete) and the context (synchronous vs. asynchronous). Below is a detailed breakdown of Sweep's order of execution, reflecting how automations are triggered and processed.
After Insert
On insert, Sweep runs in an ‘after insert’ context where the records already have an id, in order to support referencing related records.
Run Dedupe and Matching automations marked as ‘On Create’ on all records coming in the trigger.
Loop trigger records, for each record:
Run ‘On Create’ automations.
If a record has a record type that is mapped to a Sweep Funnel -
Run automations where the trigger is related to funnel - On Step Enter
Check for automatic progress gates
Run automations where the trigger is related to funnel - On Step Exit
Call batch job to run Sweep Rollups where the child object equals the triggering object. async
Perform an update call on all records in the trigger’s context (do not call Sweep again).
Post trigger -
Update & delete records collected by dedupe & matching async
Call jobs to run all async actions collected in the trigger async
Before Update
Run Dedupe and Matching automations marked as ‘On Update’ on all records coming in the trigger.
Loop trigger records, for each record:
Run ‘On Update’ automations.
If a record has a record type that is mapped to a Sweep Funnel -
Run automations where the trigger is related to funnel - On Field Update
Run automations where the trigger is related to the funnel - On Step Enter
Check for automatic progress gates
Run automations where the trigger is related to funnel - On Step ExIf not, run ‘On Field Update’ automations.
Call batch job to run Sweep Rollups where the child object equals the triggering object. async
After Update
Post trigger -
Update & delete records collected by dedupe & matching async
Call jobs to run all async actions collected in the trigger async
After Delete
Call batch job to run Sweep Rollups where the child object equals the triggering object async.
Synchronous vs. Asynchronous Actions in Sweep:
Synchronous Actions:
These actions are performed immediately within the same transaction context, such as:
Matching and Deduplication
Assignment Rules
Update Record (for the record that triggered the automation)
Asynchronous Actions:
Actions that are deferred to be processed later to avoid hitting Salesforce governor limits include:
Create Record
Update Related Records
Send Email
Slack Notifications (e.g., creating a channel, adding members)
Convert Lead
By organizing these actions asynchronously, Sweep helps optimize overall performance and efficiency, reducing the risk of reaching Salesforce limits like CPU timeouts.
