Sub topic 4
Flow Builder and the flow types
This chapter assumes you know the Salesforce data model (objects, fields, records) and can find your way around Setup. You don't need to read Apex.
What Flow Builder is
Flow Builder is the drag-and-drop tool in Setup for building automation without code. You build a flow on a canvas. It is made of three kinds of building blocks:
- Elements do the work: Get Records, Create Records, Update Records, Delete Records, Decision, Assignment, Loop, Screen and Action.
- Resources hold data: variables, formulas, constants and collections.
- Connectors are the lines that set the order of execution.
The first element, the start element, decides how the flow begins. That choice fixes the flow type.
The main flow types
| Flow type | Starts when | Needs a user? | Typical use |
|---|---|---|---|
| Screen flow | A user opens it from a button, tab, page or action | Yes | Guided data entry, wizards |
| Record-triggered flow | A record is created, updated or deleted | No | Set fields, create related records |
| Scheduled-triggered flow | A set time, once or on a repeating schedule | No | Nightly cleanup, reminders |
| Platform event-triggered flow | A platform event message is published | No | Reacting to events from other systems |
| Autolaunched flow (no trigger) | Called by Apex, another flow or an API | No | Reusable logic, subflows |
Later chapters cover record-triggered, screen and scheduled flows in detail. Here the point is to match the start condition to the requirement.
A first example
Suppose a rep should see a message when an Opportunity has no Amount. A before-save record-triggered flow can set a default instead. The flow has a start element on Opportunity (created or updated), a Decision that checks whether Amount is blank, and an Assignment that sets the field. In a before-save flow you don't need an Update Records element, because Salesforce saves the change along with the record.
How flows run
- Versions. Each save creates a new version. Only one version is active. You can roll back by activating an older version.
- Run context. Flows run in user context or system context. The setting changes which records and fields the flow can see and change.
- Limits. Flows share governor limits with the rest of the transaction. A Get Records or Update Records element inside a Loop can hit those limits when records are processed in bulk. Collect records in a collection variable, then run one Update Records element after the loop.
- Fault paths. Add a fault connector to elements that can fail, so errors are handled and not shown to users as unhandled errors.
Common mistakes
- Choosing a screen flow when no user needs to be involved.
- Using an after-save flow to change the triggering record, which costs an extra save. A before-save flow is cheaper.
- Leaving a flow without fault handling.
- Building one large flow for everything instead of small flows that call subflows.
Exercise
A requirement says: "Every night, close all Cases that have been Resolved for more than 30 days." Which flow type fits, and why is a record-triggered flow a poor fit?
Show answer
A scheduled-triggered flow fits, because the work starts from the clock and not from a record change. A record-triggered flow only runs when a record is saved, so a Case that stays untouched for 30 days would never start it.