Skip to content
RevOps Agentified
← All articles

GTM Systems

Set the run order for Salesforce record-triggered flows

Use Salesforce Flow Trigger Explorer to trace save order, stop duplicate onboarding handoffs and test what happens when Closed Won automation runs.

· 6 min read

  1. Before saveCopy Morgan, the active implementation owner, to the opportunity.
  2. ValidationReject the Closed Won update if the opportunity has no implementation owner.
  3. After saveUse the opportunity ID to create one onboarding record for Morgan.

In this example, a rep closes a $72,000 deal. Salesforce creates an onboarding record with the right account and the wrong owner. An enrichment sync edits the opportunity a minute later and creates a second onboarding record. The handoff flow ran whenever a deal was Closed Won, and a separate automation assigned the owner after the handoff ran.

Make the owner available before the handoff reads it. Then make the handoff run on the transition to Closed Won and give it a unique key. Start in Flow Trigger Explorer to see which part you can address by changing the order.

See what Salesforce can reorder

In Setup, open Flow Trigger Explorer, select Opportunity, and select the Updated trigger. Inspect the active flows in the before-save and after-save groups and expand their asynchronous paths. Open the version properties in Flow Builder to inspect Trigger Order, or use Edit Order in the explorer when it is available for the flows you need to move.

Within the same object and save phase, Salesforce runs flows numbered 1–1,000 first, then flows with no number in activation order, then flows numbered 1,001–2,000. Ties within a numbered group follow the flow API name. The before-save flows run before before-Apex and custom validation. The after-save flows run later, after after-Apex. An asynchronous path runs after commit. The Trigger Order field controls only its own group.

Find the last writer

For the example, start with StageName, Implementation_Owner__c and the onboarding record. For each one, identify who writes it and who reads it. Check active Apex triggers, template-created flows and integrations alongside the explorer. Template-created flows can be absent from the explorer, and standard flows cannot be reordered there. Compare the final field values after an actual sandbox save with the values the handoff stored.

Check the source of a late update before changing any priority. A second before-save flow that runs later in the same save and an integration that issues a second save can produce the same final value. Only the first case is an ordering problem you can solve in Flow Trigger Explorer.

Give each phase one job

Opportunity update example
Where it runsNative Salesforce setupResult to verify
Before saveFast Field Updates flow, order 100. Copy the account’s active implementation owner to the triggering opportunity on the Closed Won transition.The opportunity contains the owner before validation and the handoff. A missing or inactive account owner leaves the opportunity field empty.
Custom validationUse a validation rule for an update entering Closed Won when Implementation_Owner__c is blank.The rep can save other edits. Moving to Closed Won without an owner returns a field error and creates no onboarding record.
After saveActions and Related Records flow, order 100 within the after-save group. Enter when the opportunity moves to Closed Won. Look up the onboarding record by the unique handoff key before creating it.The flow creates one onboarding record with the saved owner. A later edit to Amount has no handoff effect.
After commitIf you need to notify another tool, trigger the asynchronous path from the newly created onboarding record. Have the integration use the handoff key on retries.A failed notification leaves a CRM record the integration can reconcile. Retrying the same key does not create another handoff.

In both flows, set the trigger to updates only. For the after-save flow, set the entry condition to Stage equals Closed Won and choose Only when a record is updated to meet the condition requirements. In the before-save flow, check the stage transition, look up the account’s configured implementation owner and verify that the user is active. Assign the owner directly on $Record. Explicitly clear the field if the check fails, since an older owner on the opportunity would otherwise satisfy validation.

For the update-only validation rule in this example, use AND(NOT(ISNEW()), ISCHANGED(StageName), ISPICKVAL(StageName, "Closed Won"), ISBLANK(Implementation_Owner__c)). Use the actual Stage picklist value and lookup API name in your org.

Here the contract is one onboarding record for the lifetime of an opportunity. Set a unique text field on the onboarding object and use the 18-character opportunity ID as the handoff key. If the rep reopens and wins the deal again, the flow finds the existing handoff and preserves the owner and status already in use. If your business runs separate onboardings for separate bookings on the same opportunity, key them by a durable booking ID.

Follow the $72,000 deal through a save

The account’s implementation owner is Morgan, who is active. The rep changes the stage from Negotiation to Closed Won. The before-save flow fills Implementation_Owner__c on the triggering record. Validation passes. The after-save flow inserts the onboarding record with Morgan as its owner. When enrichment adjusts employee count on the opportunity a minute later, the opportunity was already Closed Won, so the after-save flow skips the handoff. When the rep reopens and recloses the deal, the unique key points to the existing record.

Decide whether a missing handoff should block a booking. In this example, sales and implementation agreed that Closed Won without a handoff is a failed save. Route an unexpected create fault to a Custom Error in the synchronous path so Salesforce rolls back the triggering change. A duplicate-key fault from a competing request is safe to accept only when a fresh lookup finds the handoff for the same key. If you allow bookings to proceed during handoff faults, give RevOps a visible retry queue and alert on Closed Won opportunities without a matching handoff.

Test the transaction with the real entry points

Use Flow Builder test scenarios to assert the normalization flow’s record values for an active, inactive or missing owner. Then run actual saves in a sandbox through both the Salesforce UI and the API path your enrichment, quoting or CRM integration uses. A flow test and a full record save answer different questions. After every successful save, query the opportunity and onboarding records to verify the stored owner and the handoff count.

  • Single save. Close an opportunity with an active owner. Expect a matching owner on both records and one onboarding record.
  • Blocked close. Close a deal with an inactive account owner. Expect a validation error, the prior stage and zero onboarding records.
  • Repeated events. Edit Amount on a Closed Won opportunity and then reopen and reclose it. Expect the existing handoff ID, owner and status to survive both saves.
  • Bulk update. Submit 200 eligible sandbox opportunities through one synchronous bulk DML operation. Expect 200 handoffs linked to 200 distinct opportunities. Run a separate mixed batch through the same API path and check the failure behavior matches the integration’s all-or-none setting.

Release the flows as a set

Capture the active version and trigger order for each affected flow before release. In the sandbox, activate the replacement versions and retire the superseded writer together so the test matches the intended production setup. Recheck the live order after release. Review the first batch of bookings for missing owners, zero handoffs and duplicate handoff attempts. If you revert to the prior versions, keep the handoffs already created and reconcile the opportunities that closed during the release window by handoff key.

. It includes an example automation inventory and expected results for UI, API, fault and bulk tests.

For automations that change account ownership, use the account-owner data contract to agree which system owns the field. If your stack has multiple trigger frameworks, start with the automation architecture guide.

Keep reading

When a deal enters Closed Won, which must happen first, saving the implementation owner or creating the handoff?

Check your answer

Save the owner before validation. Create the handoff after the save so it reads the assigned owner and runs only on the qualifying transition.

Get the Salesforce Flow test pack

Subscribe to the GTM Systems Academy newsletter to download the file.