Sub topic 1
What a Record-Triggered Flow Is and When It Runs
Prerequisites
This chapter assumes you understand Salesforce objects, fields, and related records. You should also know basic Flow Builder elements and Boolean formulas. A database transaction is the group of changes saved together.
What a Record-Triggered Flow Is
A record-triggered flow is an automation that Salesforce starts when a record changes. It can run when a record is:
- Created
- Updated
- Deleted
The flow runs inside the transaction or from a later path, depending on its configuration. For example, an Opportunity flow can set a field when an Opportunity is created, or create a Task after an Opportunity becomes Closed Won.
The flow does not run for every record automatically. Its start settings determine which records and events qualify.
Configuring the Object and Trigger Event
In the Start element, select the object that owns the change, such as Opportunity. Then select when the flow should run:
- When a record is created
- When a record is updated
- When a record is created or updated
- When a record is deleted
Choose the narrowest event that meets the requirement. A flow that only responds to a stage change should not run for every Opportunity update.
Entry Conditions and Run Frequency
Entry conditions filter records after the trigger event matches. For example, an update flow can require that the new stage is Closed Won:
AND(
ISCHANGED({!$Record.StageName}),
{!$Record.StageName} = "Closed Won"
)The ISCHANGED test prevents the flow from running again when another field changes while the stage remains Closed Won.
For update-triggered flows, choose whether the flow runs every time the record meets the conditions or only when it changes from not meeting them to meeting them. The second choice often prevents unnecessary repeated work.
Reading Current and Prior Values
$Record is the flow variable containing the record that caused the flow to run. Use it to read current field values, such as $Record.StageName.
$Record__Prior contains the record’s values before the update. It is available for update-triggered flows, so you can compare old and new values:
{!$Record.StageName} != {!$Record__Prior.StageName}Exercise
Which variable should you use to detect that an Opportunity changed from Prospecting to Closed Won?
Show answer
Compare $Record.StageName with $Record__Prior.StageName.