Skip to main content
New tool CRON Expression Builder — preview next run times before you schedule Apex. Open the builder →
Flow

Salesforce Flow: The Complete Guide to Declarative Automation

Salesforce Flow has replaced Workflow Rules and Process Builder. This pillar covers the four flow types, when to use each, best practices, debugging, and the detailed guides on bulkification, triggers, and the new Transform element.

The short answer

Salesforce Flow is the platform's declarative automation tool that enables admins and developers to build visual business logic without writing Apex code. It executes across 4 distinct flow types on the multi-tenant runtime, officially replacing legacy Workflow Rules and Process Builder.

Key takeaways Since Winter '23, Flow replaces Workflow Rules and Process Builder for new builds. Both jobs now go to a Record-Triggered Flow. There are four flow types: Screen, Auto-Launched, Record-Triggered and Schedule-Triggered. Pick by who or what starts the work. Before-save handles same-record edits and is roughly 10x faster than after-save. Anything crossing records goes after-save. Never put a Get, Create, Update or Delete element inside a loop, add a fault path to every DML element, and test with 200 records.

Salesforce Flow has gone from "the slow option" to "the default option" over the past four releases. As of Winter '23, Workflow Rules and Process Builder are deprecated for new builds. This pillar links every Flow guide on the site, organized by the questions you'll actually have.

What is Salesforce Flow?

Salesforce Flow is the platform's declarative automation tool, a visual canvas where admins build business logic without writing Apex. It runs on the same multi-tenant runtime as Apex, respects the same governor limits, and works against every Salesforce object.

Since Winter '23, Flow officially replaces Workflow Rules and Process Builder. Both jobs now go to a Record-Triggered Flow. Approval Processes can still stand on their own, but Flow is the modern alternative for new approval logic.

Lightning Web Components remain for UI and Apex remains for complex code. For most "when X happens, do Y" patterns, though, Flow is now the right answer.

The four flow types

Type Trigger UI? Common use
Screen Flow User clicks a button or follows a guided link Yes Wizards, forms, guided record creation
Auto-Launched Called from Apex, another flow, REST API No Reusable subroutines, integrations
Record-Triggered A record is inserted, updated, or deleted No Replaces most workflow rules / process builders
Schedule-Triggered A cron schedule No Nightly cleanup, batch updates

Most orgs use all four eventually. Pick by who or what triggers the work.

Record-Triggered Flow: the workhorse

This type replaces what Workflow Rules and Process Builder did. There are two timing options.

Before-Save (Fast Field Update) runs before the database save. It can only modify fields on the same record being saved, and it is roughly 10x faster than after-save because there is no second save cycle. Use it for default values, normalization, and calculated fields.

After-Save runs after the database save. It can update related records, send emails, call Apex, and invoke approval processes, and the records have an Id by then, which matters on inserts. It is slower, and it is the only one of the two that can act across records.

My rule: same-record edits go before-save, everything else goes after-save.

Best practices

Bulkification, fault paths, and trigger choice decide whether your flows survive production. The full list of 12 rules: Salesforce Flow Best Practices: 12 Rules That Prevent 90% of Errors.

The non-negotiables:

  1. Never put a Get, Create, Update, or Delete element inside a loop. Build collections, then operate on them once.
  2. Always add a fault path to every DML element. Without one, failures are invisible to users.
  3. Pick before-save or after-save deliberately. Before for self-record edits, after for everything else.
  4. Test with 200 records. A flow that works for one record can crash on a Data Loader job.

The Transform element (Spring '24+)

The Transform element does collection mapping without a loop. Instead of building a new collection one iteration at a time, you describe the input to output mapping:

Input collection: List of Cases
For each Case → output a CaseResult with {
  CaseId = case.Id,
  Subject = case.Subject + ' [PRIORITY]',
  AssignedTo = case.OwnerId
}

The runtime executes that in a single pass. You end up with fewer elements, less governor-limit exposure, and something you can still read six months later. See: Salesforce Flow Transform: Collections Without Loops.

For aggregate-style transformations (sum/count over a collection), see Salesforce Flow Transform Aggregations: Sum & Count.

Debugging flows

Three tools, in the order I reach for them:

  1. Flow Builder's Debug button runs the flow with test inputs and shows the value of every variable at every step. This is where I start, every time.
  2. Process Automation debug logs. Setup → Process Automation → Process Automation Settings → enable. Captures full state on every flow run for selected users.
  3. Setup → Apex Jobs. Triggered flow exceptions surface here, which catches people out. For the "the flow ran but did nothing" mysteries, this is where the answer usually hides.

For the deeper debugging playbook including silent-failure patterns, see the Flow best practices post linked above.

Order of execution

Flows sit in a specific spot in the save lifecycle:

  1. Before triggers
  2. Custom validation rules
  3. Record commits to buffer
  4. After triggers
  5. Assignment / auto-response rules
  6. Workflow field updates (legacy; can re-trigger steps 1-6 once)
  7. Process Builder / Flow trigger automations
  8. Roll-up summary recalcs
  9. Sharing rules
  10. DB commit
  11. Post-commit (emails, async, Platform Events)

Trigger automations run after after-triggers. That is why a flow can't easily react to a change a trigger just made: the trigger fires, then the flow runs, and the two are often going for the same fields. The full reference: Salesforce Order of Execution.

Deep-dive guides

Common Flow mistakes

  • DML inside a loop. Same as Apex: build collections, operate once.
  • Forgetting fault paths. The failure is silent, so the user just watches nothing happen.
  • One mega-flow per object. Split by intent (validation vs notification) and by trigger event (insert vs update).
  • Skipping bulk testing. A flow that works for one record can crash on a 200-row import.
  • Not picking before-save when it applies. That 10x difference adds up.
  • Recursion via workflow re-triggers. Use the $Flow.CurrentRecord recursion guard or check stamp fields.

Flow is quicker to build than Apex, easier for the next admin to pick up, and fast enough now for production work that matters. Pick the right type, keep it bulk-safe, and give every DML element a fault path.

Frequently asked questions

What is Salesforce Flow?

Salesforce Flow is the platform's declarative automation tool, a visual canvas where admins build business logic without writing Apex. Since Winter '23, Flow has officially replaced Workflow Rules and Process Builder. It supports four flow types (Screen, Auto-Launched, Record-Triggered, Schedule-Triggered) covering everything from guided UI wizards to background record updates.

What are the types of Salesforce Flow?

Four types: (1) Screen Flow, interactive forms users complete via the UI; (2) Auto-Launched Flow, invoked from Apex, REST API, or other flows with no UI; (3) Record-Triggered Flow, which runs before or after a record save (replaces most Apex triggers); (4) Schedule-Triggered Flow, which runs on a cron schedule against a record set. Each type has different element availability and limits.

When should I use Salesforce Flow vs Apex?

Use Flow when the logic fits a visual canvas, an admin should be able to maintain it, and it's a CRUD-style operation. Use Apex when the logic is genuinely complex (recursion, deep transformations), you need fine-grained governor-limit control, or performance matters in tight loops. Salesforce's official guidance is 'configure first, code last', so start with Flow.

How do I make a Salesforce Flow bulk-safe?

Three rules: (1) never put a Get Records, Create Records, Update Records, or Delete Records element inside a loop, and build collections instead; (2) use the Transform element (Spring '24+) for collection-to-collection mapping rather than loops; (3) test with 200 records in a sandbox before deploying. The full discipline is in our Flow best practices guide.

What is a Record-Triggered Flow?

A Record-Triggered Flow runs automatically when a record is created, updated, or deleted. There are two timing variants. Before-Save (Fast Field Update) runs before the database save, can only modify fields on the same record, and is roughly 10x faster. After-Save runs after the save and can update related records, send emails, or call Apex. Choose by which records you need to modify.

How do I debug a Salesforce Flow?

Three approaches: (1) Flow Builder's debug button runs a flow with test inputs and shows step-by-step execution; (2) enable debug logs from Setup → Process Automation → Process Automation Settings to capture every flow run with full state; (3) for triggered flows, check Setup → Apex Jobs (yes, even for Flows; they show up there) for unhandled exceptions.

Are Salesforce Flows replacing Apex triggers?

For most CRUD-style automations, yes. Salesforce officially recommends Flow over triggers. Apex still wins for complex logic, callouts that need fine-grained control, and anything requiring dynamic SOQL or queueable patterns. In modern orgs, simple field-update triggers are migrated to before-save Flows; complex business logic stays in Apex. Trigger frameworks remain useful in code-heavy orgs.

Newsletter

One email every Tuesday

New guides, tool updates, and the release-note changes that break things.

No spam. Unsubscribe in one click.

Comments

Loading comments...

Leave a Comment