OBLYTECH Logo
OBLYTECH Logo

Record-Trigger Ordering Review Before Each Release

Before a Salesforce release reaches production, review the order of before-save and after-save automation on each object that receives changes. List each record-triggered flow and Apex trigger, note its save phase, count the automations, and confirm that one entry point governs the object. Then test the sequence with bulk-sized data.

Why save phase and sequence change the outcome

Record-triggered logic runs in phases around the database save. A before-save step updates the triggering record before the first database commit, so its changes are written along with the record. An after-save step runs once the record has been written, and that is where changes to related records belong. Moving a step from one phase to the other changes what the user sees on save, which values later steps read, and how the sequence behaves under load.

Flow and Apex share basic capabilities such as querying records, running conditional logic and performing DML. Sharing those basics does not make the two tools interchangeable. A release review asks which tool owns each step and where that step sits in the sequence, because the choice affects performance, maintainability and how the work scales as record volume rises.

Count automations and assign each object a density level

Automation density is the load placed on one object. It has three measures: the number of automations that execute during a single data manipulation event, the number of records processed per transaction, and the number of downstream DML operations one change sets off on related objects. Score all three before deciding how much structure an object needs. The bands below are a working scale for this review, not figures Salesforce sets, so calibrate each boundary against your own org.

  • Low density: fewer than 15 automations, user-driven edits or small API loads of roughly 1 to 200 records, self-contained logic, and zero to one downstream DML operation. Record-triggered flow is the usual choice.
  • Medium density: 15 to 30 automations, batch work that needs careful bulkification, coupled parent and child updates, and two to four downstream DML operations. Recursion risk begins to appear. The hybrid pattern, a record-triggered flow calling invocable Apex, fits here.
  • High density: more than 30 automations, bulk API loads of 2,000 to 10,000 or more records, five or more downstream DML operations, and a dependency graph that can loop back on itself. Apex triggers, often organized with a trigger framework, are the usual choice.

Count the automations that execute during one save on that object. Recount after any release that adds, removes or reactivates an automation, because the total is what moves an object across a level boundary.

Map the before-save and after-save sequence on each object

Build a sequence sheet for each object before the release is scheduled. Use one row per automation, with columns for the mechanism, the save phase, the relative order, the objects it writes to, and the last batch size tested. Then work through these steps.

  1. Record the mechanism. Each automation is either a record-triggered flow or an Apex trigger, and the object should have one main entry point. Mark any flow that calls invocable Apex so it is read as part of the hybrid path.
  2. Mark the save phase. A step that changes fields on the triggering record belongs in the before-save group. A step that touches related records belongs in the after-save group.
  3. Set the relative order. In Flow, Flow Trigger Explorer is where administrators set the relative execution order of the record-triggered flows on one object. In Apex, that order lives in code, typically in the handler structure of a trigger framework. Write the number on the sheet rather than relying on the order in which the names sort.
  4. Flag the deferred paths. Note any scheduled path and any asynchronous path, because both run outside the save that started them.

Run the ordering checks before the release is approved

Run these checks against each object once the sheet is complete. Each one covers a failure that a quick sandbox pass tends to miss.

  • Before-save steps stay on the triggering record. Confirm that each step in the before-save group updates the record that started the save. A before-save step that reaches into a related record moves to the after-save group.
  • Cross-object reads have a recorded writer. For each after-save step that reads a value, find the step that writes it and confirm the relative order. A pair with no recorded order is untested, whatever the sandbox showed.
  • Recursion has a stop condition. Look for chains in which an update on one object fires automations that update the first object again. Each chain needs a condition that stops the second pass. Medium and high density objects need this check first.
  • Mixed DML has a path. A transaction that changes a setup object, such as a user or a group, and a non-setup object in the same run can produce a mixed DML error. Moving one of those operations into an asynchronous path is a common way to separate them. Test each such step with a record that actually triggers it.
  • Asynchronous volume fits the org. Asynchronous work runs under its own limits, which are separate from the synchronous figures covered on the governor limits for admins page. Add the daily DML total from the sheet to the asynchronous execution count for the org, and confirm the current limit figures in the org before the release is approved.
  • Validation messages sit where they can block a save. A custom error in a before-save flow can block the save, and Apex addError() can attach a message to a specific field on the triggering record. Check that each validation sits in a context that supports the mechanism it uses, and test one blocked save per validation.

Test the sequence with bulk-sized data

A sequence that passes with a few test records has not been tested at the load it will carry. Low density objects can be tested with batches in the 1 to 200 range that matches user edits and small API loads. Medium and high density objects need the larger batches that bulk API loads reach, from about 2,000 records up to 10,000 or more.

Run three stages. Start with one save made through the user interface and confirm the before-save changes appear on the record. Next run a small API load and compare related-record counts with the sheet. Last, run the largest batch the object can receive in production, and check the field values the after-save steps wrote.

Pair this pass with the release notes review before each sandbox test, so the sandbox run covers the changes the notes flag. Apex triggers should also go through the developer checklist for bulk-safe triggers. For the limit figures to compare results against, use the governor limits for admins page.

Decide when an object needs a different mechanism

Sometimes the sheet shows that the order can no longer be controlled in the current mechanism. A low density object that gains several automations in one release moves to medium density. At that point, move the heavy logic into invocable Apex and keep the ordering in the flow. An object that reaches high density moves to an Apex trigger, with its automations under that single entry point.

Splitting one object’s automation across several mechanisms makes the sequence harder to follow and harder to govern, so avoid it where you can. Treat a change of mechanism as a release item of its own, with a separate test pass. Moving an object to Apex in the same release as an unrelated feature makes it hard to tell which change caused a problem.

For help planning this work, see Salesforce implementation.

Keep a running order register for each object

Store the sequence sheet next to the release notes, so the next review starts from the last one. For each object, keep one register row with the date of the last review, the density level, the entry point, the relative order and the last test batch size. Update the row before a change ships, not after.

Keep the register short. A row with a name, a phase and a number is enough for a reviewer to spot a conflict quickly. A stale register is worse than none, because it looks reliable.

Questions about reviewing trigger order before a release

Can a record-triggered flow roll back part of a save?

No. Flow has no access to savepoints, rollbacks or partially successful DML, so it cannot commit part of a transaction. Apex provides that control through Database.savepoint and Database.rollback. If a step needs partial commits or a rollback, plan that step in Apex.

Can Apex cache results between steps in one transaction?

Apex can. Static properties and variables allow transactional caching within one transaction, and Platform Cache can store data for reuse at the platform level. Flow gives no direct equivalent of static variables for passing state between steps, so repeated lookups on a flow-heavy object are harder to consolidate.

Should an object run flow and Apex triggers side by side?

Avoid it where you can. Choose one main entry point per object. The hybrid pattern works because the flow stays the entry point and Apex handles the heavy logic the flow calls. Two competing entry points divide the order between two tools.

Why did a step pass in the sandbox and fail after release?

Volume is the first thing to check. Asynchronous work runs under its own governor mechanisms and capacity limits, and those limits can depend on the org’s licensing. A sandbox run with a few records can pass while a bulk load on the same object reaches a daily limit. Rerun the test at the batch size production receives.

Can a flow run an action on a set date tied to a record?

Yes, with a scheduled path in a record-triggered flow. An example is a step that fires three days before a close date. The platform manages the timing of that path for the record that started it. Scheduled Apex is a separate mechanism, defined by a cron expression, and the sequence sheet should record which mechanism an object uses for time-based work.