Salesforce Flow tutorial: screen, record-triggered and subflows
On this page (9 sections)
Lesson 1: Types of FlowLesson 2: Record-triggered flowsLesson 3: Screen flowsLesson 4: Subflows and reusable logicLesson 5: Testing, debugging and good practiceWhat changed in 2025–26How this is asked in interviewsPractise this topicCommon questionsFlow is Salesforce's main tool for automation without code. Workflow Rules and Process Builder are retired, so every admin is expected to build Flows, and developers need to know when Flow is enough and when Apex is better.
In this topic: Lesson 1: Types of Flow · Lesson 2: Record-triggered flows · Lesson 3: Screen flows · Lesson 4: Subflows and reusable logic · Lesson 5: Testing, debugging and good practice
Lesson 1: Types of Flow
| Flow type | Starts when | Typical use |
|---|---|---|
| Record-triggered | A record is created, updated or deleted | Update fields, create related records, send notifications |
| Screen Flow | A user launches it from a page, button or action | Guided forms and wizards |
| Schedule-triggered | At a set time, for a batch of records | Nightly clean-up, reminders |
| Autolaunched (no trigger) | Called by another Flow, Apex, an agent or a process | Reusable logic, agent actions |
| Platform event-triggered | A platform event message arrives | React to events from integrations |
Lesson 2: Record-triggered flows
Build one in Setup, then Flows, then New Flow, and choose Record-Triggered Flow. Choose the object, when it runs, and the entry conditions.
| Option | Use it for |
|---|---|
| Fast field updates (before save) | Changing fields on the same record. Fastest option, no extra save. |
| Actions and related records (after save) | Creating or updating other records, sending emails, calling actions. |
| Asynchronous path | Slow work or callouts that shouldn't delay the user's save. |
| Scheduled path | Work later, relative to a date (for example 3 days before Close Date). |
- Set entry conditions so the flow runs only when needed, for example "Status is changed to Closed" using Only when a record is updated to meet the condition requirements.
- Use
$Recordfor the new values and$Record__Priorto compare with the old values. - Add elements: Get Records, Decision, Assignment, Create Records, Update Records.
- Add fault paths to handle errors, then Debug and activate.
Tip: Never put Get, Create, Update or Delete elements inside a loop. Collect records in a collection variable and save them once after the loop, or the flow will hit limits during data loads.
Lesson 3: Screen flows
A screen flow shows one or more screens to a user, collects input and then does the work. Add it to a Lightning page with the Flow component, to a quick action, or to an Experience Cloud site.
- Use components such as text inputs, picklists, lookups and data tables; set component visibility to show fields only when needed.
- Use reactive screens so values update on the same screen without moving to the next one.
- Pass the current record in with an input variable named
recordId. - Add custom LWC components to screens when a standard component isn't enough.
Lesson 4: Subflows and reusable logic
A subflow is a flow called from another flow, usually an autolaunched flow with input and output variables. Use subflows to write logic once (for example "create onboarding tasks") and reuse it in many flows.
- Create an autolaunched flow and mark the variables it needs as Available for input or Available for output.
- In the parent flow, add a Subflow element and map the inputs and outputs.
- Keep subflows small and focused, and give them clear names and descriptions.
Lesson 5: Testing, debugging and good practice
- Use Debug in Flow Builder to run the flow with test values and see each step.
- Create flow tests for record-triggered flows so you can re-run them after changes.
- Keep a small number of record-triggered flows per object and set Trigger Order when several run on the same event.
- Store values that change (thresholds, email addresses) in custom metadata, not inside the flow.
- Know when to use Apex instead: very complex logic, large data volumes or complex integrations.
What changed in 2025–26
- Workflow Rules and Process Builder are retired: Salesforce ended support on 31 December 2025. Existing ones still run but get no fixes; use the Migrate to Flow tool.
- Repeater lets users add several rows of the same fields in a screen flow. Since Spring '26 the Data Table component also supports sorting and inline editing for text, email, checkbox, phone, number, percent and currency fields.
- Flow approval processes are the newer, more flexible way to build approvals.
- Trigger Order on record-triggered flows controls which flow runs first on the same object.
- Agentforce actions can call autolaunched flows, so well-built flows become building blocks for AI agents.
How this is asked in interviews
- "Before-save or after-save?" Same-record field updates in before-save; related records, emails and actions in after-save.
- "Flow or Apex?" Flow first if it stays simple and maintainable; Apex for complex logic, high volume or tricky callouts.
- "A flow failed in production. What do you do?" Read the error email, reproduce with Debug, then add fault paths and logging.
- "How did you migrate Process Builder?" Migrate to Flow, review, test with bulk data, then deactivate the old one. See Flow questions.
How to answer: Start with what you would do, say why, mention the limit or risk you are avoiding, and finish with a real example from a project or practice org. One clear minute beats five minutes of definitions.
Practise this topic
- Flow practice exercises, with model answers
- Salesforce Flow interview questions
- Flow scenario questions
- Record-triggered flow questions
- Flow mock interview
Common questions
01Should I use a before-save or after-save flow?
Should I use a before-save or after-save flow?
Use before-save (fast field updates) when you only change fields on the record that triggered the flow. Use after-save when you need the record Id, update other records or perform actions.
02Can a flow call Apex?
Can a flow call Apex?
Yes. Write an Apex method with @InvocableMethod and it appears as an action in Flow Builder.
03What happened to Workflow Rules and Process Builder?
What happened to Workflow Rules and Process Builder?
Salesforce has retired them, so new automation should be built in Flow. Use the Migrate to Flow tool to convert existing ones.