Salesforce Flow best practices come down to six habits. Keep flows simple. Plan before you build. Reuse subflows. Keep queries and saves out of loops. Add fault paths. Test with bulk data before you activate.
Clientell AI, the AI Salesforce admin, reads every flow in your org. It flags missing fault paths, queries inside loops and overlapping triggers. Start with the free, read-only Salesforce flow audit.
What is Salesforce Flow Builder?
Salesforce Flow Builder is the point-and-click tool that automates work in Salesforce. It reads data, updates records and runs business steps without code. To see your flows, go to Setup > Process Automation > Flows.
Pick the flow type that matches the trigger.
| Flow type | Best used for | Key benefit |
|---|---|---|
| Screen flow | Guided steps with input forms | Wizard-like screens for users |
| Autolaunched flow | Background work with no user input | Other flows or Apex can call it |
| Schedule-triggered flow | Jobs that run at set times | Batch updates on a schedule |
| Record-triggered flow | Work that starts when a record changes | Runs as the data changes |
For hands-on practice with the record-triggered type, use the Trailhead module on record-triggered flows.
What are the best practices for building Salesforce flows?
1. Keep each flow small
Complex flows are harder to troubleshoot. They also hit limits sooner and hide more logic errors. Build the simplest flow that meets the need. If a flow grows, split it into subflows that each do one job.
2. Plan before you build
Draw a flowchart first. Write down:
- The inputs and outputs.
- Every decision and its conditions.
- Every path a user or record can take.
- What happens when a step fails.
3. Use subflows for reusable parts
A subflow is a flow that other flows call. Change the logic once and every caller gets the change. Good jobs for a subflow are address checks, email alerts and permission checks. The glossary entry on subflows shows the pattern.
4. Use a before-save flow for same-record changes
If a record-triggered flow only sets fields on the record that started it, choose Fast Field Updates under Optimize the Flow for. This makes it a before-save flow, so the change saves without a second database write. Choose Actions and Related Records only when the flow must create other records or send email. Setting Opportunity.NextStep from Opportunity.StageName is a good before-save job.
5. Design for volume
- Avoid hard-coded values. Store IDs, names and thresholds in variables, constants or custom metadata.
- Work in collections. Hold the records in a collection variable such as
varContactsToUpdate. Save the whole collection with one Update Records element. - Write down the purpose. Use the flow description to say what it does and who owns it.
What are the common pitfalls when building Salesforce flows?
Pitfall 1: Overcomplicating one flow
A flow that tries to handle every case fills up with elements and conditions. It works for a small team and breaks when volume grows. Keep to the core need and move side tasks into subflows. Review old flows each quarter.
Pitfall 2: Putting Get Records or Update Records inside a loop
A loop that runs a query or a save on each pass looks fine in a test with one record. A bulk load then runs one query for every record. The fix has three steps:
- Run Get Records once, above the loop.
- Inside the loop, use an Assignment element. It changes each record in memory and adds it to a second collection.
- Run Update Records once, after the loop, on that collection.
Pitfall 3: Skipping error handling
A flow with no fault path stops on the first error. The user sees a generic message.
Add a fault path to every element that touches data. Have it write the error to a log record or email an admin, and include $Flow.FaultMessage in the text. The Trailhead module on fault paths shows each step.
Pitfall 4: Building several flows that fight over one object
Two record-triggered flows on the same object can update the same field in an order you did not plan. Search for Flow Trigger Explorer in Setup Quick Find to see the flows on an object and set their run order. The Trailhead unit on Flow Trigger Explorer explains how. If an object has many flows, merge related ones into one and branch with Decision elements.
Which advanced Flow features are worth learning?
- Apex actions run custom Apex code from a flow. Use them for logic that Flow cannot express, or for callouts to outside systems.
- Loops step through a collection. Use one to set a field on every open Opportunity of an Account.
- Wait elements pause a flow until a date or event. Use one for a follow-up task when no reply arrives.
How do I fix a flow that updates Contacts in a loop? A worked example
Take an after-save flow on Account. It sets Contact.Description on every related Contact. The first version runs Update Records inside the loop.
- Open the flow from
Setup > Process Automation > Flowsand save it as a new version. - Move Get Records (object
Contact, filterAccountIdequals the triggering Account) above the loop. - In the loop, add an Assignment that sets
Descriptionon the loop variable. Add that variable tovarContactsToUpdate. - Delete the Update Records element inside the loop. Add one Update Records element after the loop that saves
varContactsToUpdate. - Add a fault path from that Update Records element. Send the error to an admin with
$Flow.FaultMessage. - In a sandbox, debug the flow with rollback mode on, then load a bulk file of Accounts with the Data Import Wizard and watch for errors.
You should see one query and one save per transaction, not one per Contact. If the load still fails, open a debug log and search it for LIMIT_USAGE. To undo the change, activate the earlier flow version from the flow's detail page.
How should I test a flow?
Test in a sandbox first, with one record and then with a bulk load.
| Test | What it proves |
|---|---|
| Debug in Flow Builder | The logic takes the path you expect for one record |
| Debug as another user | The flow works for the people who really run it |
| User acceptance test | End users can finish their real scenarios |
| Bulk test | The flow stays under limits at data-load volume |
| Regression test | A change did not break an older flow |
Our guide to Salesforce flow debugging walks through the Debug button, rollback mode and debug logs.
Which governor limits break flows in production?
A governor limit is a cap Salesforce puts on one transaction so no single job can use all the shared resources. A flow that tested clean with one record can fail on a bulk import because of one of these caps. Salesforce lists them in the Apex governor limits cheat sheet. Flows share the same pool as Apex.
| Limit | Per transaction | What usually causes it |
|---|---|---|
| SOQL queries (Salesforce Object Query Language, the query behind Get Records) | 100 | Get Records inside a loop |
| DML statements (data manipulation language, meaning creates, updates and deletes) | 150 | Update Records inside a loop |
| Records returned by queries | 50,000 | A broad Get Records on a large object |
| Heap size (memory) | 6 MB synchronous, 12 MB asynchronous | Big collections with Long Text fields |
| CPU time | 10 seconds synchronous, 60 seconds asynchronous | Heavy formulas and nested loops |
Source for every row: the Salesforce Developers limits cheat sheet. See also the glossary entry on governor limits.
Older flows have one more cap. Flows saved at API version 56.0 or earlier stop after 2,000 executed elements. Salesforce removed that cap in API version 57.0, as its help article on the iteration error explains. Open the flow's version properties to check which API version it uses.
Which Flow patterns scale?
These four patterns hold up at volume.
1. Collect, then enrich. To copy Account fields onto many Contacts, first get the Contacts into a collection. Loop once to gather the Account IDs. Run one Get Records for all those Accounts.
Then loop again and assign each field from the matching Account.
2. Stage gate. For an Opportunity stage change with checks, build a screen flow on the record page with clear exit criteria. Reps see what blocks the move, and the data is captured right away.
3. Hand heavy work to async code. Let the record-triggered flow call an Apex action that starts a queueable job (a background Apex job). The flow finishes at once and the heavy work runs in the background.
4. Error triage. Every fault path writes to a custom error object. A scheduled flow then emails admins a daily digest, so silent failures surface within a day.
Where does AI flow building fit?
AI changes how fast you build a flow, not the rules the flow must follow. You still need bulk-safe loops, fault paths and a known run order. Check AI output the same way you check a teammate's work: sandbox first, a second pair of eyes, and a way to roll back.
Run changes in a sandbox first. Clientell AI asks before it changes anything in production. Read the security and privacy details.
Try it in Clientell AI: "List my record-triggered flows on Opportunity. Show which have no fault path or a Get Records inside a loop. Propose a fix for each."
Run it on the 14-day trial, no card, or see how Clientell AI builds Salesforce flows from plain English.
Related Tools
Common questions about Salesforce Flow Builder best practices
Can flows fully replace Apex?
For most declarative automation, yes. Apex stays necessary for callouts that need retries, for recursive logic and for batch jobs that keep state. It is also the choice when the code needs unit tests.
How many flows are too many on one object?
You have too many when you can no longer say which runs first. Merge related flows into one and branch with Decision elements. Use Flow Trigger Explorer to check the order of what is left.
What is the safest way to retire an old flow?
Deactivate it in production but keep it in your metadata. Watch for one full business cycle to confirm nothing downstream broke. Then delete it. Another flow may depend on its side effects.
Are subflows better than copy-pasting logic?
Almost always. If three flows each hold the same address check, a rule change means three edits and three chances to miss one. A subflow means one edit.
How do I test a flow before activating it?
Run it in a sandbox with one record and then with bulk data. Use Debug in Flow Builder for single records. For bulk, write an Apex test class that triggers the flow and checks the result.
Sources
Salesforce documentation
- Apex governor limits cheat sheet, Salesforce Developers
- Flow iteration error in API version 56.0 and earlier, Salesforce Help
- Record-Triggered Flows, Trailhead
- Meet Flow Trigger Explorer, Trailhead
- Handle Flow Errors with Fault Paths, Trailhead
Industry research
Last reviewed October 2026
Last updated: October 22, 2026




