OBLYTECH Logo
OBLYTECH Logo

Asynchronous Handoff for Quote Approvals Outside the Save Transaction

Queue a quote approval step asynchronously when the rep does not need the outcome before the save returns. Keep the step inside the save when a failed approval must block the save. Queued work runs in a separate transaction after the save commits, so the rep does not wait on the approver.

Decide whether the approval must finish before the save returns

A quote approval step usually does two things. It records that a request exists, and it decides whether the quote can move forward. Those two jobs need different timing. If the rep only needs to see that the request is pending, the approval can run after the save. If the rep cannot continue until the approval has answered, the decision has to happen inside the save.

Write that decision down for each step before you build anything. A step that sets the quote to a pending status, posts a request to an approver and notifies that approver splits cleanly. A step that blocks a save when the discount passes a threshold does not, because the rep needs an answer on the same screen. Discount checks often fall into that second group.

Signs the approval can run after the save

  • The rep can see a pending status and keep editing the quote.
  • The approver responds on a schedule of their own, or an external system answers the request.
  • The work updates related records rather than the quote being saved.
  • The business accepts that the result may arrive later than the save. Asynchronous work carries no guaranteed completion time, and a busy queue can delay it.

Signs the step has to stay in the save

  • The save must fail when the approval rules fail.
  • The rep must read the outcome before moving to the next section of the quote.
  • The change is a simple field update on the record being saved. A before-save record-triggered flow can make that change in memory, so it is committed with the original save and needs no second write.

For help planning this work, see Salesforce implementation.

How the save transaction and the queued transaction differ

Everything that runs inside the save belongs to one transaction. Before-save changes to the triggering record are made in memory and written with the original save, which avoids a second write and a recursive save. After-save work is different. The Run Asynchronously path runs in a separate transaction once the original save has committed.

The Asynchronous Path option in record-triggered flows moves an after-save update out of the rep’s save. Use it when the update to a related record can wait until the save has committed, so the rep’s save does not carry that second write.

The separation has two practical effects. First, the save is already committed when queued work runs, so a failure there cannot undo the rep’s edit. The failure has to be recorded and recovered separately. Second, an unhandled exception inside the save rolls back the whole save. A heavy approval calculation inside the save therefore puts the rep’s edit at risk. The same calculation in a queued job affects only that job.

Steps for moving a quote approval step out of the save

Start by listing each automation that fires on the quote for the event you are moving. The platform does not guarantee the order in which multiple triggers on the same object and event run, so write down the order you expect and check it in a test. For the wider set of automation types on a record, see automation workflows in Salesforce.

Build the synchronous part first

  1. Keep the part that runs in the save small. Set the status field the rep will see, along with the fields the approval rules read.
  2. Create the request in an after-save step. Use the Run Asynchronously path for a simple external callout or a single related-record update that does not need an immediate answer.
  3. In Apex, enqueue the job from the trigger handler and pass record IDs to the queued class. The queued job returns a job ID. Store that ID on the quote or on a log record so an administrator can trace the request later.
  4. Choose Apex when you need deduplication, custom error handling or closer control over performance. Choose Flow for simple cross-object DML after save.

Build the queued job and its follow-on steps

A queued job should do one bounded piece of work. If an approval sets off a cascade of updates across several related records, split the cascade into a chain of asynchronous transactions. Queueable Apex supports this pattern, because each job can enqueue the next. Keep each link small enough to finish well inside its limits. Record the state after each link, so a later link can resume from the right point if one of them fails.

Checks to run before you release the change

Run these checks in a sandbox with a bulk set of records rather than a single test quote. A single quote can hide limit problems.

  • Count the expected executions per day for the chosen tool and compare that number with the limits that apply to that tool. Base the count on every user who edits quotes, not on one rep’s test data. For the limits themselves, see governor limits for admins.
  • Move any complex API callout out of the save. Complex callouts increase the risk of breaching governor limits, while a simple external callout fits the Run Asynchronously path.
  • Search trigger code for direct System.schedule and Database.executeBatch calls, and move them into queued work where the design allows. Those calls are the ones most likely to add work to every save.
  • Confirm that no other flow or trigger expects the queued work to finish before the save returns.
  • Watch the asynchronous job queue during the bulk test, and confirm that each job completes.

Tracking whether a queued approval finished

A queued approval can finish later than the rep expects, so the quote needs a visible state for the period in between. Use a pending status set in the save, and a completed or failed status set by the queued work. Give the rep a status value that says the request is waiting, not one that says the approval is done. For how pipeline reviews use those stage values, see the forecast review in Salesforce.

When a rep reports a quote stuck in pending, check three things in order. First, look for the job ID stored on the quote. Second, check whether the queued job completed or failed. Third, check whether the approver’s action reached the quote. A missing job ID usually means the enqueue call never ran, which points back to the trigger logic rather than to the approval itself.

Recursion, bypass and retry behavior

A queued job that updates the quote fires the same automation that enqueued it, because its update counts as a new save. Prevent that loop by comparing new and old field values. In flow entry criteria, use $RecordPrior. In Apex, use Trigger.oldMap. A static flag alone is a weak guard, because a queued job runs in a new transaction where the flag starts empty.

For a deliberate bypass during data loads or maintenance, use a custom permission. Check it with $Permission in flow entry criteria, or with FeatureManagement.checkPermission() in Apex. Grant the permission to the people who run that maintenance, so the bypass does not turn into a standing exception.

Retry behavior depends on the tool, so decide it before you build. Apex gives you savepoints and manual retry logic, and you write both. Whichever tool you choose, plan the retry inside the queued work, and record enough detail that a failed job can be re-queued without duplicating the request.

Worked example: a discount approval on a pending quote

Consider a rep who saves a quote with a discount above the approval threshold. The save sets the quote status to pending approval and writes a small log record. An after-save step enqueues a job that creates the approval request for the discount approver.

When the approver responds, the queued job sets the status to approved or rejected. If the job fails, the log record still shows a request that was queued but not completed, so an administrator can re-queue it. The next stage should check the status value, so the quote cannot advance while it reads pending.

Questions about queued quote approvals in Salesforce

Can a rep see the result of an approval that runs after the save?

Not until the queued work completes. The save shows the pending status, and the final decision appears when the queued job updates the quote. How long that takes depends on queue load and on how much work the job does, so the rep should expect a wait rather than a fixed time.

Why can a scheduled job not replace the queued approval?

A scheduled job fits only when the approval itself is time based, such as a reminder that fires after a set number of days. It does not replace an approval that the save triggers, because the rep’s save should not wait on a clock.

Should the approval logic use Flow or Apex?

Flow fits simple cross-object DML after save and needs less code to build. Apex gives more control over deduplication, error handling and performance, but it needs manual bulkification and retry logic.