The SchemaForce Team

Flows vs triggers vs validation rules: what runs first in Salesforce

Before-save flow, before trigger, validation rule, after trigger, after-save flow — the order they fire decides which one wins, and it trips up admins and devs constantly. What runs first, why it matters, and when to reach for a flow versus a trigger.

Cover Image for Flows vs triggers vs validation rules: what runs first in Salesforce

Here's the thing you came for: the order that flows, Apex triggers, and validation rules fire in when a record is saved — because that order is what decides which one wins. The cheat sheet below has the full sequence; this post is the part people actually trip on, which is the handful of steps around the save itself.

Salesforce Order of Execution Cheat Sheet
Excel (.xlsx) · the full save sequence, per phase, with the gotchas
Download the cheat sheet
We're adding a version that maps the order onto YOUR org's actual automations per object — get an email when it lands.

Three kinds of automation can touch a record on save — a flow, an Apex trigger, and a validation rule — and the single question that causes the most confusion is simply which one goes first. The answer isn't "the one you built first" or "it depends." It's fixed, and here's the part that matters:

The order, around the save

For a record being saved, the relevant slice of Salesforce's order of execution is:

  1. Before-save flow — runs first, before any Apex.
  2. Before Apex triggerbefore insert / before update.
  3. Validation rules (then duplicate rules).
  4. The save to the database.
  5. After Apex triggerafter insert / after update.
  6. …then assignment, auto-response, and workflow rules
  7. After-save flow — which is why it can see values workflow set.

Read that top to bottom and the common "why did that happen" answers fall out:

  • Your before-save flow runs before your before-trigger. If both set the same field, the trigger wins, because it runs later and overwrites. If you expected the flow's value to stick, this is why it didn't.
  • A validation rule can reject a value your flow or before-trigger just set. Validation runs at step 3 — after the before-logic. So "my automation sets this field, but I get a validation error" is not a contradiction; the rule is validating exactly what your automation produced.
  • An after-save flow sees more than a before-save flow. It runs at step 7, after triggers and workflow, so it has the record's ID and the results of everything upstream. That's the right place for "create a related record" logic — and the wrong place to cheaply set a field on the record itself.

So which should you use?

  • Before-save flow — to set fields on the record being saved. It's the cheapest option (no extra DML, no code) and Salesforce's own guidance is to prefer it over a before-trigger for simple field updates. Reach here first.
  • Before Apex trigger — when the logic is genuinely beyond a flow: complex bulk processing, callouts' prep, things declarative tools can't express. Runs just after the before-save flow.
  • Validation rule — to enforce integrity. Because it runs after the setters, it validates near-final values — which is usually what you want, but means it can catch values your own automation created.
  • After-save flow — for related records and anything needing the saved record's ID.

The honest caveat

Two of these steps hide something the tidy list can't show. Within a single step, order isn't guaranteed: if two before-save flows run, or three after-update triggers fire, Salesforce doesn't promise which goes first. You control the phase, not the order inside it — so the fix for "these two automations fight" is usually to consolidate them, not to try to sequence them. (The full order of execution covers the whole sequence and this caveat in depth.)

The honest catch — this is the generic order, not your org's

Knowing the sequence is half of it. The other half is knowing what's actually on your object: which before-save flows, which triggers, which validation rules you've accumulated, and where each one lands in this order. That list isn't in any doc — it's whatever your org happens to have, and reconstructing it means opening every automation on the object and placing it by hand.

That's what SchemaForce's Process Map does for you: it reads an object's automations and lays them out in this exact order-of-execution sequence, banded by phase — honestly not pretending to know the within-phase order Salesforce doesn't guarantee. The order above is yours to memorize; what the tool removes is assembling your object's real one from memory and forty Setup tabs.

Flows, triggers, and rules · in order, for your object
what you actually have, banded by phase
your object's automations placed in execution order
which one wins is a glance, not a guess
Blast radiusbefore-save flowbefore triggervalidationafter-save flow
The order is fixed; your object's automations aren't. SchemaForce's Process Map lays out an object's real save sequence so you can see which automation wins, without opening every one.See your object's real order, free
ShareLinkedInX

See your own org in minutes.

Connect Salesforce, explore every object and field, and ask your schema anything — metadata only, free to start.