Sub topic 1
Flow Types and What Triggers Them
Every flow starts in one of a small number of ways. Before you can debug or test a flow, you need to know which type it is and what starts it. The type decides who the flow runs as, what data it receives, whether it can show a screen, and how you can reproduce a failure. This chapter covers the main flow types and their triggers, and it points out where each type behaves differently when you debug it.
Prerequisites
This chapter assumes you have:
- Basic Flow Builder skills: creating a flow, adding elements, and using variables.
- Familiarity with Salesforce objects, fields, and records.
- Access to a sandbox or Developer Edition org, so you can open each flow type and look at its start element.
- Basic Apex syntax, for the one short Apex example near the end.
Why the Type Matters for Debugging
Two flows with the same logic can fail in different ways. A flow that updates a field behaves one way as a screen flow, where a user clicks a button. It behaves another way as a record-triggered flow, where the same update runs inside a save operation and shares limits with other automation. When you diagnose a failure, ask these questions first:
- What started this interview? An interview is one running instance of a flow.
- Which user or context did it run as?
- How many records or events did it process in one go?
- Can I recreate the trigger on demand?
The answers come from the flow type and the settings on the Start element.
The Flow Types
Screen Flows
A screen flow shows screens to a person and collects input. A user starts it from somewhere in the interface, such as:
- A Lightning page, where the flow is embedded as a component.
- A quick action or button on a record page.
- The utility bar or a tab.
- An Experience Cloud site.
A screen flow is the only type that can display screens. It normally runs in user context, so the running user's permissions apply. When a screen flow fails, the user sees an error message on screen, and the details often arrive as a flow error email. You can reproduce most failures by opening the same page as a similar user and entering the same values. The Flow Builder debugger can run a screen flow directly and shows the screens as the user would see them.
Record-Triggered Flows
A record-triggered flow starts when someone creates, updates, or deletes a record of a chosen object. You configure these settings on the Start element:
- Object: the object to watch.
- Trigger: a record is created, updated, created or updated, or deleted.
- Entry conditions: conditions that the record must meet before the flow runs. On update, you can also require that the flow runs only when a record is changed to meet the conditions.
- Optimize the flow for: this setting splits the flow into two kinds.
Before-save flows ("Fast Field Updates") run before the record is written to the database. They can change fields on the triggering record only. They cannot create other records, send emails, or call actions. Because they skip a separate DML operation, they are fast. A common surprise is that the record has no Id yet when a before-save flow runs on create, so {!$Record.Id} is empty.
After-save flows ("Actions and Related Records") run after the record is saved. They can create or update related records, call subflows and Apex actions, and send emails. The record has an Id. Changing the triggering record from an after-save flow causes an extra update, which can fire automation again.
Before-delete flows run before a record is deleted. You can use them to block a delete or to act on the record first.
After-save flows can also use a scheduled path or an asynchronous path. These run later, in their own transaction. That separation matters in debugging because an error on those paths does not roll back the original save.
Record-triggered flows run in the same transaction as the save that started them. This is why they are subject to governor limits shared with Apex triggers, other flows, and validation rules. The next chapters cover that in detail.
Schedule-Triggered Flows
A schedule-triggered flow runs at a set time and frequency: once, daily, or weekly. You can choose an object and filter conditions, and Salesforce then runs the flow for each record that matches. Without an object, it runs once per schedule. Salesforce processes the matching records in batches, so one run can span several transactions. These flows run as the Automated Process user, not as a person.
For debugging, there is no screen and no user to watch. You rely on the debugger, flow error emails, and debug logs. You also cannot trigger one on demand outside the debugger. To test one, you temporarily set a schedule that starts soon, or you test the same logic with an autolaunched flow.
Platform Event-Triggered Flows
A platform event-triggered flow starts when a platform event message is published. A platform event is a custom message type that systems or other automation can publish. The flow receives the event as {!$Record}. By default it runs as the Automated Process user, although you can configure a different running user.
Because the publisher and the subscriber are decoupled, the flow does not run in the publisher's transaction. A failure in the flow does not show up for the person or process that published the event. You have to look at the flow's own error emails and logs.
Autolaunched Flows (No Trigger)
An autolaunched flow has no screens and no built-in trigger. Something else starts it:
- Another flow, as a subflow.
- Apex code.
- The REST API.
- A button or action configured to launch it.
It defines input and output variables, which are the contract with its caller. The flow runs as part of the caller's transaction. If a parent flow calls it, they share the same limits. This type is the easiest to test in isolation, because you control the input values directly.
Flow Orchestration
Flow Orchestrator coordinates multistep processes that span users and time, such as approvals with several assigned steps. It is a separate tool, and this tutorial does not cover it in depth. It is useful to know it exists, because orchestrations run other flows as steps, and an error in a step flow appears under the orchestration's run.
Comparing the Types
| Flow type | What starts it | Can show screens | Typical running context | Easy to reproduce |
|---|---|---|---|---|
| Screen | A user action in the UI | Yes | The current user | Yes, by repeating the UI steps |
| Record-triggered | Create, update, or delete of a record | No | The user who saved the record, in the save transaction | Yes, by making the same record change |
| Schedule-triggered | A set time and frequency | No | The Automated Process user | Only through the debugger or a short test schedule |
| Platform event-triggered | A published platform event | No | The Automated Process user by default | Yes, by publishing a test event |
| Autolaunched (no trigger) | A caller such as Apex, a flow, or the API | No | The caller's context | Yes, with chosen inputs |
How the Types Relate
The diagram groups each type by what starts it.
Starting an Autolaunched Flow from Apex
Because autolaunched flows take defined inputs, you can start one from Apex. Run the code below in Anonymous Apex. Replace Calculate_Discount, inputAmount, and outputDiscount with the API names from a flow you have built, which needs an input variable and an output variable.
Map<String, Object> inputs = new Map<String, Object>();
inputs.put('inputAmount', 1500);
Flow.Interview interview = Flow.Interview.createInterview('Calculate_Discount', inputs);
interview.start();
Object discount = interview.getVariableValue('outputDiscount');
System.debug('Discount from flow: ' + discount);The variable names are case-sensitive and must be marked as available for input or output in the flow. If a name is wrong, the call fails or returns null, and that is a common first error when you test this type.
Execution Context and Why It Affects Failures
The running context causes many failures that are hard to reproduce:
- Permissions. A screen flow runs with the current user's permissions, so a flow that works for an administrator can fail for a standard user. The same flow can pass the debugger and still fail in production.
- Automated Process user. Schedule-triggered and platform event-triggered flows run as this system user. It has no profile you can edit in the same way, and records they create show it as the owner or creator.
- Shared transactions. Record-triggered and autolaunched flows share limits with everything else in the transaction. A flow that works for one record can fail when a data load saves 200 records at once.
- Entry conditions. A record-triggered flow that never seems to run often has entry conditions that the record does not meet. Check them before you suspect a bug in the flow logic.
Debugging Implications by Type
| Flow type | Where to start looking |
|---|---|
| Screen | Debug in Flow Builder with test inputs, then repeat as an affected user |
| Record-triggered | Debug with a chosen record, check entry conditions, then test with several records |
| Schedule-triggered | Debug with a sample record, then check error emails and logs after the real run |
| Platform event-triggered | Publish a test event and inspect the flow's own failure records |
| Autolaunched | Pass known inputs through the debugger or an Apex test |
The following chapters build on this. You will use the debugger, fault paths, debug logs, and tests, and each one works a little differently depending on the type.
Common Mistakes
- Choosing before-save for logic that needs related records, then wondering why the elements are unavailable.
- Updating the triggering record from an after-save flow when a before-save flow would avoid the extra save.
- Testing a scheduled flow only once in the debugger and never checking how it behaves for a full batch.
- Testing as an administrator and missing permission errors that real users hit.
- Looking for a platform event flow's errors in the publisher's transaction instead of in the flow's own error information.
Exercise
A flow must set a field on the Opportunity that the user is saving, and it needs no other records or actions. Which trigger setting should you choose, and why?
Show answer
A record-triggered flow optimized for Fast Field Updates (before save). It changes fields on the triggering record before the write, so it avoids an extra DML operation, and it uses fewer resources than an after-save flow.
Exercise
A schedule-triggered flow runs every night, and nobody saw it fail. Which running user does it use by default, and what does that tell you about where to look for errors?
Show answer
It runs as the Automated Process user, so no person sees an on-screen error. You look at flow error emails, the failed interview information, and debug logs rather than waiting for a user report.
Exercise
A before-save record-triggered flow on record creation tries to use {!$Record.Id} to create a related record. Why does this fail, and what is the fix?
Show answer
Before-save flows run before the record is written, so the record has no Id on create, and before-save flows cannot create other records anyway. Use an after-save flow, where the record has an Id and related records can be created.