Sub topic 2
What Flow Is and the Flow Types
This chapter assumes you know the Salesforce data model (objects, fields, records), can find your way around Setup, and have seen a simple automation built before. It also assumes basic programming ideas such as variables, loops, and collections. Apex was covered in the previous chapter. Here you build the same working model for Flow, so you can compare the two tools fairly later.
What Flow is
Flow is Salesforce's declarative automation tool. You build logic on a canvas in Flow Builder by placing elements and connecting them with arrows. You do not write code. Each saved flow is metadata, and Salesforce runs it on the platform.
A flow has three parts:
- A start. This defines what launches the flow: a user clicking a button, a record being saved, a schedule, or a call from another tool.
- Elements. These are the steps. They read data, make decisions, change data, show screens, or call actions.
- Resources. These are the values the flow works with: variables, collections, formulas, constants, and text templates.
Flow is now the standard declarative automation tool on the platform. Salesforce ended support for Workflow Rules and Process Builder on December 31, 2025. If you meet either in an older org, treat it as something to migrate to Flow. The Salesforce migration tool can convert many of them, but you should review the result.
The building blocks
You will use the same families of elements in almost every flow type.
| Element family | Examples | What it does |
|---|---|---|
| Data | Get Records, Create Records, Update Records, Delete Records | Reads and writes Salesforce data. Each one is a query or a DML operation. |
| Logic | Decision, Assignment, Loop, Collection Filter, Collection Sort, Transform | Branches, sets values, and works through collections. |
| Interaction | Screen, Action, Subflow | Shows UI, calls an action (email, Apex, a platform feature), or runs another flow. |
| Error handling | Fault path | Defines what happens when an element fails. |
Two ideas from programming carry over directly:
- A variable holds one value or one record. A collection variable holds many, like a list.
- A Loop element visits each item in a collection. The same care applies as in Apex: do not put a query or a data change inside the loop. Collect the records in the loop, then make one Create, Update, or Delete after it.
A flow can have many versions, but only one version is active at a time. You can edit and debug an inactive version safely, then activate it when it is ready. This gives you built-in rollback: activate the previous version.
The flow types
The flow type is chosen when you create the flow. It decides what starts the flow and what the flow can do. The main types are below.
| Flow type | Starts when | Typical use |
|---|---|---|
| Screen flow | A user opens it (button, Lightning page, utility bar, Experience Cloud site) | Guided data entry, wizards, case intake |
| Record-triggered flow | A record is created, updated, or deleted | Set fields, create related records, send notifications |
| Scheduled-triggered flow | A set time, once or on a repeating schedule | Nightly cleanup, reminders for records that match a filter |
| Platform event-triggered flow | A platform event message is published | React to events from other systems or other automation |
| Autolaunched flow (no trigger) | Something else calls it: another flow, Apex, or the REST API | Reusable logic, subflows, work that Apex hands off |
| Orchestration | A person or system starts it, then it runs staged steps | Multi-step, multi-person approvals and fulfillment |
The sections below cover the types you will use most.
Screen flows
A screen flow is the only type that shows a user interface. Screen elements hold input fields, choice lists, file uploads, and display text. Screen flows run in the context of the user who launches them, so that user's permissions normally apply to the data the flow reads and writes. Screen flows also run one interview at a time. Bulk behavior is rarely a worry here, but limits still apply.
Record-triggered flows
Record-triggered flows are the type you will compare with Apex triggers most often. You choose an object, then choose when it runs: on create, on update, on create or update, or on delete. You then add entry conditions, which limit the flow to records that match. A common setting for updates is to run only when a record is updated to meet the conditions. That setting stops the flow from firing again on every later edit of a matching record.
You must also choose how the flow is optimized, which sets when it runs relative to the save:
- Fast Field Updates (before save). The flow runs before the record is written. It can change fields on the triggering record by assigning values to
$Record. It does not use an Update Records element for that, and it uses no extra DML. This is the cheapest option. It cannot create or change other records. - Actions and Related Records (after save). The flow runs after the record is saved, so the record has an Id and its changes are visible. It can create or update other records, call actions, run subflows, and start an asynchronous path for work such as callouts.
As a rule, use before-save for changes to the record itself and after-save for everything else. Delete flows can run before the record is removed, which is the time to check or copy data you will need.
Record-triggered flows run in system context by default. Record permissions and field-level security do not stop them from reading or writing data. This is convenient, but it means you must make sure the flow does not expose or change data in a way the user could not do directly.
Scheduled-triggered flows
A scheduled-triggered flow runs at a time you pick, and repeats once, daily, or weekly. You choose an object and filter conditions. At each run, Salesforce finds the matching records and processes them in batches. This type replaces many old time-based workflow actions. Plan for volume: if thousands of records match, the flow handles them in bulk, and the limits discussed in a later chapter apply.
Platform event-triggered flows
A platform event is a message that one process publishes and others can subscribe to. A platform event-triggered flow subscribes to one event type. When a message arrives, the flow runs with the event's fields available. Use it when something outside the record save, such as an integration or another automation, needs to start work without being tied to a database change.
Autolaunched flows
An autolaunched flow has no trigger of its own and no screens. Another caller starts it. The caller can be another flow (as a subflow), Apex, a REST API call, or an action configured in Setup. You define input and output variables on the flow by marking them as available for input or output. The caller then passes values in and reads results out. Autolaunched flows are the best way to build reusable logic once and call it from many places.
Orchestrations
An orchestration (Flow Orchestrator) coordinates work across several steps and several people. It uses stages and steps, and each step can be an interactive flow assigned to a user or a background flow. You will use it for long processes that pause until someone finishes a task. Most automation does not need it.
Flow and the transaction
A record-triggered flow does not run in its own separate world. It runs inside the same database transaction as the save that triggered it. That has three consequences:
- Its queries, data changes, and CPU time count against the same governor limits as any Apex code in the transaction.
- If an error is not handled and the flow fails, the whole transaction can roll back, including the user's original save.
- Other automations on the same object, such as Apex triggers and other flows, run in the same transaction too.
The next chapters return to each of these in detail. For now, remember that "no code" does not mean "no limits".
Common mistakes with flows
- Using after-save when before-save is enough. An after-save flow that updates the triggering record with an Update Records element costs an extra DML and can re-trigger automation. Use before-save for same-record field changes.
- Putting data elements inside a loop. A Get Records or Update Records element inside a Loop runs once per item. With 200 records, that is 200 queries or updates, and the flow can hit a limit.
- Vague entry conditions. A flow that runs on every update of every record is slow and can loop through its own changes. Write conditions that describe the exact change you care about.
- No fault paths. Without a fault path, a failed element shows the user a generic error, and the transaction can roll back. Add fault paths to elements that can fail, and decide whether to log the error, notify someone, or stop the flow.
- Several flows on the same object and event. Salesforce does not guarantee the order of record-triggered flows unless you set one. Flow Trigger Explorer in Setup lets you view and set the order. Keep flows per object small and clear to avoid conflicts.
- Forgetting context. A system-context flow can change fields the user cannot edit. Screen flows may behave differently for users with different permissions.
What this means for choosing between Flow and Apex
Flow can handle a large share of business automation: setting fields, creating related records, sending emails, guiding users through screens, and running on schedules. It is faster to build, easier for admins to read, and needs no test class. Its limits are the same transaction limits as Apex, and it has less control over complex logic, error handling, and custom data structures. The following chapters cover where Flow is the right first choice, and where Apex is better.
Exercise
A requirement says: "When an Opportunity is saved with Stage set to Closed Won, set the Close Reason field to 'Won' on that same Opportunity, and also create a follow-up Task for the owner." Which flow type and optimization would you use for each part, and why?
Show answer
Use a record-triggered flow on Opportunity, run on create or update, with an entry condition that Stage is Closed Won (and ideally only when it is updated to meet that condition). Setting Close Reason on the same record is a before-save job (Fast Field Updates): assign the value to $Record with no extra DML. Creating the Task is an after-save job (Actions and Related Records), because the Task needs the saved Opportunity's Id. In practice you can use two flows, one for each optimization, or you can do both in one after-save flow, which costs an extra update on the Opportunity. The two-flow design is cheaper.
Exercise
A flow loops through a collection of 150 Contact records and, inside the loop, uses an Update Records element on each one. What is wrong, and how do you fix it?
Show answer
The Update Records element inside the loop runs one DML operation per item. Across many records, this can reach the DML limit and is slow. The fix is to change each Contact in the loop with an Assignment element, add each changed Contact to a collection variable, and then use one Update Records element after the loop to update the whole collection.