Every Salesforce developer hits the same decision point repeatedly: should this be a Flow or should it be Apex? There is no universal answer. But there is a consistent logic, and once you have it, the decision becomes straightforward for the majority of cases.
This session covers both tools, where each one wins, where the decision gets genuinely difficult, and the mistakes developers and admins make in both directions.
What Flow is
Flow is Salesforce's declarative automation tool. You build logic visually — elements, connectors, decisions, assignments, loops — without writing code. It runs natively on the Salesforce platform with full access to your data model.
Flow replaced Workflow Rules and Process Builder, both of which Salesforce deprecated. If you are still thinking in terms of "this should be a Process Builder," update that mental model now. Flow is the recommended default for automation in Salesforce.
Flow types you need to know
- Record-Triggered Flow — runs automatically when a record is created, updated, or deleted. The primary replacement for Workflow Rules and Process Builder.
- Screen Flow — creates guided interfaces for users. Multi-step forms, wizards, data capture processes.
- Scheduled Flow — runs on a schedule. Useful for batch updates and nightly operations.
- Platform Event-Triggered Flow — responds to platform events. Enables event-driven architecture without code.
- Autolaunched Flow — called from other contexts: Apex, another Flow, the REST API.
The type you'll use most is Record-Triggered. It handles the vast majority of common automation scenarios and should be your first consideration when automating record-based processes.
What Apex is
Apex is Salesforce's proprietary programming language. It's Java-like in syntax, runs natively on the platform, and gives you access to capabilities that declarative tools cannot touch: raw transaction control, complex exception handling, external HTTP callouts, and fine-grained bulk processing.
The key distinction: Flow is point-and-click logic. Apex is code you write, deploy, and maintain. Both run on the platform. Both access your data. The question is which one handles the problem correctly.
The decision framework
Apply these questions in order. The first one that gives you an answer is usually the right one:
- Can this be built clearly in Flow? → Build it in Flow.
- Does this require an external HTTP callout? → Apex (or an Invocable method called from Flow).
- Does this involve bulk processing at scale? → Batch Apex or Queueable Apex.
- Is the logic too complex for Flow to express clearly? → Apex.
- Does the team that will maintain this know Apex? → Factor this in before choosing Apex.
- Is this replacing a Workflow Rule or Process Builder? → Flow.
When Flow wins
Flow is the right tool for most Salesforce automation. Use it when:
- The automation is record-triggered — create, update, or delete.
- You need a guided screen flow for user input.
- The logic involves simple to moderate cross-object updates.
- Non-developers on the team need to read or modify the logic.
- You are replacing a Workflow Rule or Process Builder.
- The logic can be expressed clearly without becoming a visual maze.
The maintenance advantage is significant and often underweighted. A Flow can be read and modified by someone who is not a developer. When your admin needs to update a field reference at 9pm because the business changed, a Flow they can open is recoverable. A trigger they cannot open is not.
When Apex wins
Apex is necessary when the problem genuinely requires capabilities outside Flow's scope:
- External HTTP callouts to third-party APIs.
- Bulk data processing over thousands of records — Batch Apex or Queueable Apex.
- Complex exception handling with specific retry logic.
- Transaction control: explicit rollbacks, savepoints, DML ordering.
- Platform events where the sequence of record updates is complex.
- The Flow has become unreadable — the logic is too complex for the visual builder to express clearly.
Governor limits and bulk processing
Governor limits are one of the primary reasons to choose Apex in certain scenarios. Salesforce limits how many SOQL queries, DML statements, and resource-intensive operations can run per transaction. Both Flow and Apex are governed — but Apex gives you direct control.
In Apex, you can explicitly bulkify DML operations, cache SOQL results, manage transaction boundaries, and use Apex interfaces designed for high-volume operations. For processing thousands of records in a single job, Batch Apex is the right tool.
The hybrid pattern: Flow + Invocable Apex
The decision is not always binary. You can write Apex decorated with @InvocableMethod and call it directly from a Flow element. This lets you build the logic structure in Flow — readable, maintainable, visual — while calling Apex only for the specific part that needs code-level control.
Example: a Screen Flow that guides a user through a multi-step account creation process, with a single Invocable method call for the external address validation API. The Flow owns the structure. Apex handles the capability gap.
The scenarios table
| Scenario | Recommended Tool |
|---|---|
| Lead converted → create a follow-up Task due in 3 days | Record-Triggered Flow |
| Opportunity closes → POST data to external CRM, update records from response | Apex (callout) |
| Process 10,000 Contact records nightly to update a score field | Batch Apex |
| User needs guided multi-step form to create Account and related Contacts | Screen Flow |
| Replace a Workflow Rule that updates an email field on Opportunity close | Record-Triggered Flow |
| Commission calculation: 12 conditions, multi-object DML, rollback on failure | Apex trigger |
| Screen Flow with guided UI + single external API callout for address validation | Flow + Invocable Apex |
Testing
Salesforce requires 75% test coverage before you can deploy Apex to production. This forces you to write unit tests before shipping. That requirement is a feature, not just a constraint — it catches regressions before they reach your users.
Flow testing exists but the tooling is less mature. For critical business logic, Apex's mandatory coverage requirement is a form of quality enforcement that is worth having.
The maintenance cost people underestimate
Apex must be deployed via a change set or package — it goes through a managed change process. A bug in production Apex requires a deployment cycle to fix. Flow changes can be activated directly in production (though they shouldn't be, for the same change management reasons).
Apex requires a developer to maintain. If your team doesn't have a developer, Apex becomes a liability: it sits in the org, does its job, and nobody can touch it when something goes wrong. The failure mode is common and expensive.
Common mistakes in both directions
- Using Apex because you're a developer and it's comfortable — even when Flow handles it cleanly.
- Using Flow for everything because it's "no-code" — even when the Flow becomes unreadable and unmaintainable.
- Building the same logic in both a Flow and an Apex trigger — conflicting automation is hard to debug.
- Not testing either properly — assuming it works because it was built correctly.
- Not bulkifying Apex — writing queries or DML inside loops that will hit governor limits in production.
- Not migrating from deprecated Workflow Rules and Process Builder — building on an eroding foundation.
Flow in 2026
Salesforce has invested heavily in Flow's capabilities in recent years. If you haven't looked at what Flow can do in the last 12 months, look again. The platform has added:
- Transform Element — data transformation within flows without Apex.
- Flow Orchestration — multi-step, multi-user processes that go beyond a single Flow.
- Subflows — reusable Flow components called from parent flows.
- Debug mode — step-through execution to diagnose issues.
The practical implication: scenarios that previously required Apex may now have a clean Flow solution. Check before defaulting to code.
The rule is simple: start with Flow. Move to Apex when Flow becomes a workaround. Use Invocable methods to combine both where the problem calls for it. Don't skip tests on either.
Session 88 next — Salesforce Apex Triggers
realsyllabus.com