Sub topic 1
Flow Types and What Triggers Them
Prerequisites
Assume you can create Flow Builder elements, use Salesforce records and fields, and read basic Apex. You also need access to a sandbox or Developer Edition org.
Flow Types and Triggers
A flow is an automated process that runs when its starting conditions are met. The flow type determines how it starts and what context it receives.
- Record-triggered flow: Starts when a record is created, updated, or deleted. It can run before the record is saved or after the save completes.
- Schedule-triggered flow: Starts at a defined time and can process records that match criteria.
- Screen flow: Starts when a user opens it. Screens collect input during an interactive session.
- Autolaunched flow: Starts from Apex, another flow, an API call, or an action. It has no screens.
- Platform event-triggered flow: Starts when Salesforce receives a matching platform event.
A record-triggered flow often depends on whether a field changed, not only on its current value. For example, a flow can run when an Opportunity changes to Closed Won.
flowchart TD
A[Trigger event] --> B{Flow type}
B --> C[Record change]
B --> D[Schedule]
B --> E[User opens screen]
B --> F[Apex or API call]
C --> G[Flow interview runs]
D --> G
E --> G
F --> GDebugging a Flow in Flow Builder
Use Debug in Flow Builder to run a saved flow with test inputs. Flow Builder displays each element as it executes. Review the starting values, decisions, assignments, queries, and actions. The first element with an unexpected value usually identifies where the behavior diverged.
For record-triggered flows, select a record or provide its ID when the debug interface supports it. Test both matching and nonmatching records. A decision that silently follows the default path is a common source of confusion.
Debug Options: Input Values, Rollback, and User Context
Debug runs can accept values for flow variables. They can also run in rollback mode, which undoes database changes after the run. Rollback lets you inspect creates and updates without keeping test data.
You can choose another running user when permissions, sharing, or field-level access might affect the result. This helps distinguish logic errors from access errors.
Transactions and Governor Limits
A flow runs inside a Salesforce transaction, which groups related work into one commit. Governor limits restrict queries, records, and database operations in that transaction.
Avoid Get Records, Create Records, or Update Records inside loops when possible. Collect records first, then perform one bulk operation. A flow that works for one record can fail when a data load triggers it for hundreds.
Exercise
Why might a flow succeed in Debug but fail during a bulk update?
Show answer
The bulk transaction may exceed governor limits because the flow performs queries or database operations inside a loop.