SfSkills Domains Docs GitHub

Home / flow / flow-transactional-boundaries

flow-transactional-boundaries

Reason about when a Flow is inside the caller's transaction vs starts its own. Pick Before-Save vs After-Save vs Async Path vs Pause + Resume when transaction boundaries matter. Covers governor-limit sharing, DML sequencing, recoverability, and the limits that reset when a new transaction starts. NOT for choosing Flow vs Apex (use admin/process-automation-selection) or record-triggered design — use flow/record-triggered-flow-patterns.

Open the skill folder on GitHub


Flow Transactional Boundaries

Core concept — what is a "transaction" in Flow?

A Salesforce transaction is a unit of work bounded by:

Inside one transaction:

Flow can either join an existing transaction or start its own. The choice changes everything about how the flow behaves under load and what happens on failure.

Transaction behavior per Flow entry point

Before-Save record-triggered flow

Use when: deriving field values on the same record. Setting Status__c from Amount + Stage. Copying account fields onto a case. Calculating a normalized phone.

After-Save record-triggered flow

Use when: creating related records, posting to Chatter, sending emails synchronously, updating unrelated records in the same transaction.

Scheduled Path (on an after-save record-triggered flow)

Use when: you want "eventually consistent" work that must not block the save; SLA reminders; fanout to related records; callouts.

Autolaunched flow called from Apex

Use when: Apex orchestrates the transaction but needs a declarative subroutine (admin-maintainable logic).

Autolaunched flow called as a subflow

Screen flow (user-facing)

Screen flow with a Pause element

Scheduled flow (fired by the clock, not by a record)

Platform-Event-triggered flow

Orchestration stage

  1. Read standards/decision-trees/flow-pattern-selector.md to confirm the flow subtype.
  2. Classify the work as (a) field derivation on same record, (b) inline DML across records, (c) needs callouts, (d) must be delayed / scheduled, (e) spans multiple user sessions, (f) spans multiple humans.
  3. Pick the transaction boundary per the table in this skill.
  4. Draw the boundary diagram — list every DML, every callout, every subflow and mark which transaction it runs in.
  5. Compute the governor-limit budget per boundary — if a Before-Save joins a transaction already running 85 SOQL, your flow's 15 SOQL budget is tight.
  6. Plan idempotency — any work in a new transaction must be safe to run twice (scheduled paths, platform-event fanouts retry on failure).
  7. Document the boundary diagram in the flow description so downstream maintainers don't bypass the reasoning.

Key patterns

Pattern 1 — "Derive then act" split

Before-Save derives fields on the same record; After-Save (same flow or a sibling flow) creates related records.

[Trigger record updated]
        │
        ▼
[Before-Save Flow]  ← derives Normalized_Phone__c, Region__c
        │ (same txn)
        ▼
[Record written to DB]
        │ (same txn)
        ▼
[After-Save Flow]   ← creates related Task + Chatter post
        │ (same txn)
        ▼
[Transaction commits]

Savings: the Before-Save avoids a second DML for the field update — roughly a 90% cost reduction vs an After-Save that re-updates.

Pattern 2 — "Callout-required → Scheduled Path +0"

An After-Save flow needs to call an external service. Inline callouts are blocked in a trigger context. Route via a Scheduled Path with +0 minutes.

[Record inserted]
        │
        ▼
[After-Save Flow entry]
        │
        ▼
[Scheduled Path: +0 minutes, criteria: Status = 'Ready']
        │  (new txn, fresh limits)
        ▼
[HTTP callout to vendor]
        │
        ▼
[Update record with vendor ref]

Key detail: the +0 minutes doesn't mean "immediate" — the scheduler picks up the work, typically within 1–5 minutes. Not suitable for latency-sensitive needs.

Pattern 3 — Multi-day approval via Orchestration

Instead of a screen flow with pause elements (fragile, limited to one user's session), use an Orchestration with three stages: Legal Review → Procurement Review → Customer Sign-off. Each stage is a new transaction; each assigns a work item to a named user or queue.

See skills/flow/orchestration-flows for stage authoring.

Pattern 4 — "Platform Event fanout" for decoupled writes

A single trigger needs to update 5 unrelated objects. Instead of inline After-Save DML (which shares the 10,000-row limit with the trigger), publish one Platform Event and have 5 independent PE-triggered flows each handle one target. Each subscriber runs in its own transaction with fresh limits.

Bulk safety

Error handling

Well-Architected mapping

Gotchas

See references/gotchas.md.

Testing

See skills/flow/flow-testing. Key testing concerns per boundary:

Official Sources Used

Package files