Tilman Dietrich

Salesforce Flow or Apex: choosing maintainable automation

The short answer

Choose the solution that the responsible team can reliably change and verify under the expected load. A simple business rule often points towards Flow. Interdependent processing may justify Apex or a targeted combination. Existing automation on the object is always part of that decision.

Understand the existing process first

Before adding another flow, map the path of a change: who modifies which record, which automations start and which other records are written? Include integrations and scheduled imports. This reveals whether the new requirement stays local or triggers existing processes again.

Salesforce recommends considering automation density alongside dependencies. Its guide distinguishes Flow, Flow with invocable Apex, and Apex triggers. This is architectural guidance, not a fixed rule based only on the number of flows.

Salesforce Architect: Record-Triggered Automation

Four questions to guide the decision

I suggest using this checklist for an architecture discussion. It does not replace an analysis of the actual org.

QuestionWhat to establish
Who maintains the process?Named owners, Flow or Apex skills, handover and backup coverage.
How will volume change?Individual edits, typical imports and the largest realistic transaction.
What must succeed together?Which changes must all succeed and how failures become visible.
What is likely to change?Distinguish rules that business users frequently adjust from stable technical processing.

Example: assign responsibility based on a country

Suppose an org needs to derive an assignment from a maintained country-to-owner mapping. Clarify the business rule first: what happens for an unknown country, a missing mapping or a manually assigned owner? Without those answers, neither Flow nor Apex is a complete solution.

For a small process, I would first assess a Flow prototype. If the requirement expands into complex allocation across several objects, I would compare an encapsulated Apex function with a fully declarative implementation. This is an illustrative scenario, not a tested recipe or a client case.

Changing tools does not fix a transaction problem

Flow and Apex in the same transaction share relevant platform limits. Moving logic into an Apex action does not give it an independent budget. Investigate the whole process rather than only the final error message.

Asynchronous processing also changes the workflow: a later failure is separate from the original save. Decide how pending work, retries and permanently failed operations will be identified.

Salesforce Help: How Flows Run in Transactions · Salesforce Help: Per-Transaction Flow Limits

Evidence to require before rollout

For either implementation, I would require the same business checks:

  • An individual record and a representative import produce the expected assignment.
  • An unknown country and missing configuration have deliberately defined outcomes.
  • Running the process again does not produce unwanted follow-up changes.
  • The responsible person can understand a failure; recovery and rollback are documented.
  • The solution is checked with the relevant permissions and the other automations.

Limits and scope

This guide concerns automation triggered by record changes. Screen Flows and other triggers need their own assessment.

The examples have not been executed in a Salesforce org. No compatibility with a specific release is claimed. Check current platform limits and the actual org before implementation.

Sources & further reading

← Back to the homepage