The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Choosing between Flow Builder and Apex by automation density and testing (opens in a new tab)

You will learn how Flow and Apex differ in order of execution, limits and testing, and how Salesforce's Architecture Center maps automation density levels to the tool to use.

Why read this

You will also see where testing requirements currently differ between the two.

  1. Low density: Under 15 automations: Record-Triggered Flow
  2. Medium density: 15 to 30 automations: Flow plus invocable Apex
  3. High density: Over 30 automations: Apex
Automation density levels, from low to high, and the tool the Architecture Center suggests for each

The article compares Salesforce Flow with Apex for building business automation. Flow lets Salesforce Admins build automations without code, with a gentler learning curve, while Apex is a Java-like language that needs developer resources but has no functional limits beyond what a developer can write. The author notes that Flow Builder is still powerful for agent-era work.

Order of execution is a key consideration: Flows run before Apex triggers, and Apex triggers can run multiple times in a single transaction. The author suggests architecting workflows with both points in mind so behavior matches expectations.

The Salesforce Architecture Center groups objects into three automation density levels. Low density (under 15 automations, 1 to 200 records, one downstream DML operation) suits Record-Triggered Flow. Medium density (15 to 30 automations, 200 to 2,000 records, 2 to 4 downstream DML operations) calls for a hybrid of Flow and invocable Apex. High density (over 30 automations, over 2,000 records, more than five downstream DML operations) points to Apex.

On limitations and testing, before-save flows have more restrictions than after-save flows, and some tasks such as complex list processing need Apex. Apex must pass test coverage before deployment, while Flow currently does not, though the recently introduced Flow Test Mode is a first step toward structured flow testing. The author advises testing flows and building in a sandbox before production.

Read the original at Salesforce Ben (opens in a new tab)

Worth reading?

Must-read

Flow Test Mode adds saved Test Scenarios, assertions and mock outputs to Flow Builder (opens in a new tab)

You will learn how to create and save Flow test scenarios, add assertions and mock external action outputs, and why these tests are not yet enforced at deployment.

Why read this

The piece also notes that FlowTest is a separate metadata type to include when deploying.

  1. Save Test Scenario with inputs
  2. Enable Automated Test Scenario
  3. Add assertions and mock outputs
  4. Run All for coverage and results
How a saved Test Scenario runs automatically with assertions

Salesforce’s Winter ’27 release introduced Flow Test Mode, a dedicated testing canvas for Autolaunched and Record-Triggered Flows that is currently in beta. It is enabled through the Process Automation Settings page in Setup, and the author recommends trying it in a sandbox first. Within the new canvas, builders can debug by record Id or name, test primitive collection variables by separating values with semicolons, and save reusable Test Scenarios with labels, descriptions and run options such as rollback mode. Scenarios can be run manually or set to automatic, with assertions checking expected results, such as whether an element was visited or a field has a given value, and with the choice of which flow versions to test. Mock outputs let builders supply fabricated responses for external action elements, so tests can run without calling the endpoint and can force success or fault paths.

The author highlights practical uses: rerunning a scenario that reproduces a bug until it is fixed, using saved assertions for regression testing after org changes while watching coverage and results, and testing integrations without configuring live connections. He also explains deployment: FlowTest is its own metadata type, separate from the flow, so tests must be packaged and deployed individually. Currently a flow can be deployed without its tests, making them a nice-to-have rather than an enforced requirement as Apex tests are, and the author hopes enforcement will come once the feature reaches general availability.

The piece concludes that Flow Test Mode still falls well short of Apex testing, which requires at least 75% coverage before production deployment and cannot be bypassed, while flows can currently be built directly in production. Mock outputs are a point-and-click analogue of Apex’s HttpCalloutMock approach, and the Test Discovery API can run Apex and flow tests together. Overall, the author sees the feature as a significant and promising step for Flow, though it is still in beta.

Read the original at Salesforce Ben (opens in a new tab)

Worth reading?