Sub topic 2
Configuring the object and trigger event
This chapter assumes you know the Salesforce data model, can place basic elements in Flow Builder, and understand that DML (database writes) happens inside a transaction. Here you set up the Start element of a record-triggered flow. Two choices on it decide when the flow runs: the object and the trigger event.
Where the configuration lives
In Flow Builder, create a new flow and select Record-Triggered Flow. The Start element opens a panel with these settings:
- Object: the single object whose records fire the flow.
- Trigger the flow when: the event on that object.
- Entry conditions: covered in the next chapter.
- Optimize the flow for: Fast Field Updates (before-save) or Actions and Related Records (after-save).
Set the object and event first. The rest of the flow depends on them.
Choosing the object
A record-triggered flow watches exactly one object, standard or custom. If you need the same logic on two objects, build two flows.
The object also defines what {!$Record} contains. $Record is a record variable of that object type, so every field you reference in the flow must belong to it or to a related object reached through a relationship.
Choosing the trigger event
| Trigger event | Fires when | Notes |
|---|---|---|
| A record is created | A new record is inserted | `$Record__Prior` does not exist. |
| A record is updated | An existing record is saved | `$Record__Prior` holds the values before the change. |
| A record is created or updated | Either of the above | `$Record__Prior` is empty on create. Guard any comparison that uses it. |
| A record is deleted | A record is being deleted | The flow runs before the record is removed. |
Pick the narrowest event that meets the requirement. A flow set to "created or updated" runs on more saves than a flow set to "updated". It therefore uses more of your transaction's limits and is more likely to produce surprises.
An example configuration
The flow below sets a field on the record being saved. It needs a create-or-update trigger because the rule applies to new and edited large deals.
Flow: Opportunity - Set Next Step (before-save)
Object: Opportunity
Trigger: A record is created or updated
Optimize for: Fast Field UpdatesThe entry condition and the Assignment element come later in the tutorial. At this point the flow only knows which object it watches and which events wake it up.
Common errors
- Choosing the wrong event. A flow set to "A record is created" never runs when an existing record is edited. If a requirement says "when the stage changes", you need an update event.
- Changing the object late. Changing the object on the Start element invalidates references to the old object's fields. Decide on the object before you add elements.
- Reading
$Record__Prioron create. On a create-or-update flow, a formula that compares$Recordto$Record__Priorhas nothing to compare against when the record is new. Handle that case explicitly. - Assuming the event alone is enough. An update event fires on every update of the object. Without entry conditions, the flow starts on edits that have nothing to do with your rule.
Exercise
A requirement says "When an Opportunity's Amount is edited, recalculate a discount field on that same Opportunity." Which object and trigger event would you choose, and why might "A record is created or updated" be the wrong default?
Show answer
Choose the Opportunity object and the trigger event "A record is updated", because the requirement mentions only edits. "Created or updated" also fires on inserts. That adds executions and forces you to handle a missing $Record__Prior on new records. If new Opportunities also need a discount, use "created or updated" deliberately and guard the prior-value logic.