Skip to content
RevOps Agentified
← All articles

GTM Systems

Choose Flow or Apex for a save-time rule

Decide which Salesforce lead updates belong in Flow or Apex by testing the workload, outputs and concurrent capacity decisions.

· 8 min read

  1. Normalize the LeadSet the approved source on the triggering record before save.
  2. Test the routing loadCheck whether the capacity decision needs shared data or transaction control.
  3. Verify the assignmentCompare the saved owner and fallback reason for each Lead.

A lead’s source needs a normalized value before it reaches reporting. A lead assignment also needs to weigh skills and current capacity across a roster with thousands of rows. In Salesforce, these are separate pieces of work. Give the field normalization to a before-save Flow, then test whether the capacity decision needs code.

Start with the expected record and when it must be ready

Use a record-triggered Flow optimized for Fast Field Updates when the work changes only the triggering Lead. For example, map raw source values such as Partner Webinar to an approved category and assign it on $Record. Keep the input field and the approved mapping separate. Limit entry to new leads and changes in the input field, then run the same checks through the UI and an API insert.

Measure what the complex step needs to read and write

When routing depends on a large roster, several filters and shared capacity, test with a realistic bulk request. Estimate how many eligible leads can enter together, whether they need the same roster data, and whether the assignment needs transaction control. Salesforce’s automation architecture guidance considers volume, downstream dependencies and the degree to which record operations interact.

Keep the capacity step independently testable

If the load test shows why code is useful, give an invocable Apex action the batch inputs it needs and return one result per input in order. Query candidates outside the record loop and preserve a reason for leads that cannot be assigned. If multiple transactions compete for the last slot, define how the system reserves capacity and test a collision. Where the result can wait, keep it out of the immediate lead save and track the pending state explicitly.

Check both paths with the same sample leads

Three records that prove which tool does the work
TestExpected behaviorEvidence
Create a Partner Webinar lead.The before-save flow stamps the approved source category.Read the stored Lead after the actual save.
Bulk insert 200 leads of mixed source and priority.Eligible leads get a routing decision. Unmatched ones have a fallback reason.Compare Lead IDs and owners with the roster and run results.
Two requests compete for one remaining slot.One uses the slot. The other follows the fallback policy.Compare committed assignments and capacity together.

Check the active writers on Lead

In Flow Trigger Explorer, inspect active Lead flows before adding a new entry point. Check Apex and legacy automation separately. One primary mechanism can own a record event while several narrowly scoped flows operate within that mechanism. A successful Flow Debug session covers one path. The full save confirms what the other active automations actually did.

Decide from the transaction test

Keep the cheaper field update in Flow and add a dedicated routing action only when the workload demonstrates the need. Use the Flow order guide to check competing writes and the automation debt guide to plan the retirement of the old writer.

Keep reading

A single Partner Webinar lead routes correctly. Which test would reveal a bulk-routing error?

Check your answer

Insert the 200 mixed leads together. Compare saved owners with the routing roster and inspect the fallback reason on unmatched leads.

Get the article workpaper

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