Sub topic 2
Choosing Before-Save or After-Save in Salesforce Flow
This chapter assumes you know Salesforce records, fields, formulas, and the basics of Workflow Rules or Process Builder. It focuses on translating existing automation into record-triggered flows.
Choosing before-save or after-save
A before-save flow changes fields on the record that triggered the flow. It runs before Salesforce saves the record, so it is usually the fastest choice for simple field updates.
An after-save flow runs after the record is saved. Use it when the automation must:
- Create or update other records.
- Send an email.
- Create a task.
- Call an Apex action.
- Use a scheduled path.
Use the smallest flow type that supports the required action.
flowchart TD
A[Record is created or updated] --> B{What must the flow do?}
B -->|Change fields on this record only| C[Before-save flow]
B -->|Create records or perform actions| D[After-save flow]
B -->|Run later| DTranslating criteria and run frequency
Move the original rule criteria into the flow’s entry conditions. For example, a Workflow Rule that runs when an Opportunity becomes a large Closed Won deal can use this flow formula:
AND(
TEXT({!$Record.StageName}) = "Closed Won",
{!$Record.Amount} > 100000
)TEXT() converts the picklist value so the formula can compare it with text.
Also choose when the flow runs:
- Every time the record is updated and meets conditions matches repeated evaluation.
- Only when the record is updated to meet conditions matches a transition, such as changing StageName to Closed Won.
For a previous-value comparison, use $Record__Prior:
{!$Record.StageName} <> {!$Record__Prior.StageName}Translating actions
Map each old action to a Flow element:
| Existing action | Flow equivalent |
|---|---|
| Field update on the same record | Assignment in a before-save flow |
| Email alert | Action: Send Email |
| Task creation | Create Records |
| Record creation or update | Create Records or Update Records |
| Apex action | Action: Apex |
Review field values and owner or recipient logic manually. A migrated element can exist but still use an incorrect field, email template, or record relationship.
Replacing time-dependent actions
Replace Workflow Rule time-dependent actions with a scheduled path in an after-save flow. Configure the path relative to a date field, such as CloseDate, and add the email, task, or update action to that path.
Scheduled paths require an after-save flow because Salesforce must first commit the record and schedule future work.
Exercise
Which flow type should create a Task on a related Account after an Opportunity is saved?
Show answer
Use an after-save record-triggered flow because it acts on a related record.