A Flow sets Priority__c to High for same-day parcels. Yet saved records keep showing Normal. The admin swears the Flow runs. The developer swears the trigger works. Both are right.
The Old/Bad Way: The before-save Flow sets High. Then a before trigger — written two years earlier — recalculates Priority and overwrites it. Nobody knew both existed. The "fix" was a third automation, after save, updating the record again: one more save, one more full pass through every rule.
Why this is bad: When two steps own one field, the later step always wins — silently. Fixes stacked in the wrong step run the whole order of execution twice and invite recursion.
The New/Good Way:
- Learn the order cold: before-save flows → before triggers → validation rules → save → after triggers → after-save flows → roll-ups → commit.
- Give every field ONE owner in ONE step.
- Same-record field math belongs in a before-save step, where it needs no extra update at all.
The payoff: One field, one owner, one step. The order of execution is not trivia — it is the map of who wins.
Concept
Order of Execution is the classic "do you understand the platform" question.
- Here is one record save, simplified, in order:
- The record is loaded. System validation runs.
- Record-triggered BEFORE-save flows run. BEFORE triggers run.
- System and custom validation rules run.
- Duplicate rules run. The record is saved, but not committed.
- AFTER triggers run. Assignment rules run.
- Auto-response rules run. Workflow rules run (legacy technology, though old rules still execute).
- A workflow field update re-fires the before and after UPDATE triggers, once.
- Escalation rules run. AFTER-save record-triggered flows run.
- Entitlement processing runs. Roll-up summary fields recalculate on parent records.
- Criteria-based sharing is evaluated. Then COMMIT.
- After the commit comes post-commit work: emails, platform events, and any async Apex enqueued during the transaction.
- Two things sit outside that list: Formulas are computed dynamically when read (not stored, not part of the save pipeline). Roll-ups are stored and recalculate inside the parent's save cycle.
Rule: Learn the save order. Half of all strange bugs are two steps in the wrong sequence.
Gain: A before-save flow is the cheapest place to set a field on the record being saved. No extra save cycle, no DML.
Price: The order is fixed. You cannot reorder it. Your only lever is choosing which stage to use.
Limits: A workflow field update re-runs before and after triggers once, but does not re-run validation or duplicate rules. Roll-up summaries can re-fire the parent’s own rules. Emails, async Apex, and platform events fire only after commit.
Mirror — after-save flow: Can reach related records, at the cost of a second save cycle on the same record.
Later: Every automation topic in trigger and flow architecture hangs off this timeline.
At volume: Each extra save cycle multiplies by row count. In a 10,000-row load, one needless after-save flow is 10,000 extra saves.
Core Q&A
A: A workflow field update re-runs before and after update triggers once. It does NOT re-run validation rules, duplicate rules, or most of the earlier pipeline.
- So a workflow can write a value that a validation rule would have rejected from a user interface save.
- That is a real data integrity risk, and it is a core reason to migrate legacy workflow field updates to before-save flows or before triggers, which execute inside the validated pipeline stage.
- Architect Note: This re-fire behavior is precisely why Apex trigger handlers require recursion guards.
Follow-ups (Scenario-Based)
A1: Before-save flows run BEFORE before-triggers. After-save flows run AFTER after-triggers and workflows.
- When a before-save flow and a before trigger both write to the same field on the same record, the trigger wins because it executes later in the before phase.
- An after-save flow's update triggers a NEW save cycle: extra DML statements execute, and triggers fire again.
- Before-save writes are essentially free in terms of governor limits. Same-record updates belong in the before phase whether using Flow or Apex.
A2: Turn the Order of Execution into a diagnostic checklist:
- Enable Debug Logs with profiling to isolate trigger execution vs. Flow runtime.
- Identify after-save flows and workflow field updates triggering secondary save cycles.
- Check Roll-up Summary field recalculations on wide parent records where child saves lock the parent.
- Audit criteria-based sharing recalculation and cross-object formulas forcing parent reads.
- Apply target fixes: Move same-record after-save automation into before-save, set bypass switches for data migration users, defer sharing calculations, and load parent records prior to child records to avoid row locking.
Q1. An Invoice Line must never exist without its Invoice. Which relationship?
A1. Master-Detail. The child cannot exist independently, giving you cascade delete and roll-ups automatically.
Q2. Marketing says a field they capture on the Lead never arrives on the Contact. Why?
A2. Only standard fields map automatically on conversion. Custom fields drop silently if custom field mapping is not configured.
Q3. You must store config that deploys with the app and is read inside a loop. What do you use?
A3. Custom Metadata Types. Reads consume no SOQL governor limits and records deploy cleanly in packages.
A: The sequence structure remains identical; only the tooling evolves. Record-triggered flows occupy the before and after positions previously associated with legacy tools. Legacy orgs still run migrated automation, and understanding the workflow re-fire step remains critical for explaining why legacy field updates bypassed validation rules compared to modern After-Save Flow updates that initiate a complete secondary save cycle.