Use a record-triggered Flow for simple, low-density logic such as same-record field updates, email alerts, and date-based scheduled actions. Move to Apex triggers when one save fires many automations, touches large record volumes, or needs savepoints and rollbacks. Medium density often fits a Flow that calls invocable Apex.
What automation density means for this decision
Density describes how much work a single save sets off. Count three things: how many automations fire on the same record event, how many records one transaction touches, and how deep the chain of follow-on updates runs. A record with one before-save field update and an email alert sits at the low end. A bulk data load that fires a field update, a rollup, a notification, and a cascade into related objects sits at the high end.
Once you have those three numbers, the tool choice largely follows. Low density suits a record-triggered Flow. Medium density often suits a Flow that hands the heavy step to invocable Apex. High density suits Apex triggers. Treat this as a starting point and test it against real data volumes, because a design that looks simple on one record can behave differently under a data load. If the steps are still being agreed, the sales workflow design work should come first, so the automation follows a process your team has already settled.
Where record-triggered Flow is the right first choice
Flow is the default for logic an administrator can read, test, and maintain without a developer on call. Its strongest case is a same-record field update that runs before the save. A before-save flow changes the triggering record’s own fields without issuing a separate update, which keeps the transaction small. Field defaults, date stamps, and simple derived values are the typical fit.
Flow also covers email alerts, straightforward updates to a related record, and scheduled actions tied to a date field. A reminder that fires a set number of days before a close date is a typical example. The platform handles the timing for you, so a reminder of this kind rarely needs a custom scheduler or a separate cleanup job for stale reminders.
Signs a Flow has outgrown its role
Watch for three signals. The first is a flow that queries inside a loop, or hits query and DML limits once a test grows from a handful of records to a full data load. The second is logic that must deduplicate work across many records and cannot express that cleanly with flow elements. The third is a need to undo part of the work when a later step fails. Any of these points toward Apex, and the earlier you notice them, the smaller the change. The governor limits for admins guide helps you judge how close a flow is to a limit.
Where Apex earns its place
Apex is the right tool when the transaction itself needs fine control. Three capabilities drive the decision. Savepoints and rollbacks let you undo part of a unit of work and keep the rest. Partially successful DML lets some records in a batch succeed while the failing ones are reported individually. Flow offers none of these, so a process that must succeed or fail as one piece belongs in code.
Apex also gives you maps and sets, which let you load related data once and look it up in memory rather than querying it repeatedly. It gives you standard library classes, including business hours calculations, which are awkward to rebuild in declarative tools. It lets you raise field-specific errors with addError(), so the message appears on the field that caused the problem instead of as a generic banner.
Developers writing trigger code should review the developer checklist for bulk-safe triggers before they start, since bulk failures often trace back to a small set of habits. Flow gives you little direct control over cached state across separate invocations in one transaction, so repeated, expensive logic is harder to manage declaratively.
Hybrid designs for medium-density logic
Many real objects sit between the two ends. A common shape is a record-triggered Flow that gathers the data and decides whether work is needed, then calls an invocable Apex class for the heavy step. The administrator keeps visibility of the entry point, and the developer owns the bulk-sensitive logic. The cost is a small runtime overhead each time control passes from Flow into Apex. That is acceptable at medium density, but it adds up when the chain grows long.
Two design questions shape hybrid designs. Logic that must run before the record is written needs to sit in a before-save context, and logic that must run when a record is restored needs to sit in whichever context handles undelete. Map the trigger contexts each step needs before you split the work, or you may find a gap after the design is built.
Keeping one entry point per object
Choose one primary automation entry point for each object. Running a Flow and an Apex trigger on the same object makes the order of execution harder to predict. Apex does not guarantee the order in which multiple triggers on the same object and event run, so the common practice is one trigger per object. If you need several handlers inside that trigger, route them through a dispatcher that reads configuration to set their order. For record-triggered flows on the same object, write the execution order down alongside the Apex design so the next maintainer can see it.
Moving work out of the save transaction
Sometimes the right answer is to stop doing the work inside the user’s save. Asynchronous processing gives you higher governor limits and runs on separate threads, but it brings trade-offs. Async jobs carry no guaranteed service level. Processing can be delayed when asynchronous resources are busy, and the platform limits how many asynchronous threads an org can use. A user who needs an answer before the page continues should not be left waiting on async work.
Choose the option that matches the shape of the work. Queueable Apex suits longer database operations and external callouts, and it can chain follow-on jobs so that one long cascade becomes several separate transactions. If the callout is the core of the work, the Salesforce integration architecture pages cover the calling pattern and its failure handling. Batch Apex suits very large jobs processed in chunks. Scheduled Apex runs on a cron schedule, and once a job starts, its code runs synchronously.
On the flow side, an Async Path on a record-triggered flow can run an operation on its own timing. It can also avoid mixed DML errors when the work updates a related record outside the triggering record. Scheduled Flows run in the background at a set frequency to act on a group of records.
Some options need extra care. Calling Batch or Schedulable Apex directly from a trigger is a risky pattern, and enqueueing Queueable jobs straight from a trigger carries similar risk. The number of jobs you can enqueue depends on the context the transaction runs in, so check the current limit for your release before you design a fan-out. Org-wide daily asynchronous limits also apply and need to be part of any design that issues a high volume of async calls.
A checklist before you choose a tool
- Count the automations that fire on the object for each save event, including those started from other objects.
- Estimate the records per transaction for a normal save and for a bulk data load.
- Map the chain of follow-on updates and note how many steps deep it runs.
- Decide whether the logic must roll back part of its work or treat a batch as all or nothing.
- List the trigger contexts the logic needs, such as before save, after save, or after undelete.
- Name the single entry point for the object and write down the execution order for everything else.
- Check the daily asynchronous limits that apply to your org and add up the expected async jobs.
- Test the design with a load at realistic volume, not with single-record tests alone.
Once the answers are written down, the boundary between declarative and code-based work is usually clear enough to review with the people who will maintain the automation. For help planning this work, see Salesforce implementation.
Questions about choosing Flow or Apex for record-triggered work
Can a Flow and an Apex trigger run on the same object?
The usual advice is to avoid it. Mixing a Flow and an Apex trigger on one object makes the execution order harder to predict. Pick one primary entry point, and if the other automation must stay, document where it runs and what it depends on.
Which option is fastest for a simple field update?
A before-save flow that updates the triggering record is the strongest declarative option for same-record changes, because it avoids a separate update. Move to Apex when the logic outgrows that shape, for example when it needs collections, cached state, or a rollback.
Why does a Flow hit limits during a data load?
The usual cause is that the number of records per transaction, or the depth of follow-on updates, has grown beyond what the flow was built for. Reproduce the problem with a load at realistic volume, then check the query and DML counts per transaction. If the heavy part is a loop over related records, move that step into invocable Apex.
Should a follow-up update use an Async Path or Queueable Apex?
Use an Async Path when the follow-up is a record-triggered action that can run on its own timing, especially when it updates a related record outside the triggering record. Use Queueable Apex when the follow-up involves longer database work, an external callout, or a chain of jobs. Either way, the follow-up should be work that the user does not wait on.
More in this section
- Salesforce Automation & Workflows
- One Automation Entry Point per Object: Avoiding Competing Flows and Triggers
- Salesforce Developer Checklist for Bulk-Safe Triggers
- Async Path and Scheduled Flows: Low-Code Options for Deferred Work
- Starting With the Simplest Orchestration and Adding Agent Steps Only When Needed