Introduction
Salesforce Flow is a powerful no-code/low-code automation tool. Used well, it can replace complex code and speed up business processes. Used poorly, it can create maintenance headaches, performance issues, and unexpected bugs. Below are common pitfalls to avoid when designing Salesforce Flows, with practical recommendations and code-style examples where helpful.
Pitfall 1 — Ignoring bulkification and governor limits
Record-triggered flows that process multiple records must be designed to operate in bulk. Avoid putting DML or Get Records inside loops. Instead, collect record Ids into a collection, run one query or update for all records, and use Collection Actions.
// Anti-pattern: queries or updates inside a loop (pseudo)
for each record in records:
Get Records where AccountId = record.AccountId
Update record
Best practice: Use a single Get Records or Update Records element with collections.
Pitfall 2 — Overusing fast field updates instead of scheduled paths or async processing
Using immediate updates for heavy processing can cause timeouts or exceed limits. For complex logic, consider scheduled paths, Platform Events, or Invocable Apex.
Pitfall 3 — Poor error handling and lack of logging
Without proper fault paths, flows either fail silently or throw user-facing errors. Always add Fault connectors on elements that interact with external systems or perform DML, and store errors in a custom object or send notifications to admins.
Pitfall 4 — Complex, monolithic flows
Large flows are hard to read and maintain. Break logic into subflows and reusable flow actions. Use descriptive names for variables, resources, and elements.
Pitfall 5 — Not considering transactional boundaries
Flows run in the same transaction as the triggering event. Be cautious with elements that cause additional triggers (recursive updates). Use a mechanism to prevent recursion — e.g., a checkbox field or Platform Cache.
Pitfall 6 — Inefficient queries and filter usage
Use selective filters on Get Records to avoid full table scans. Limit fields returned and use indexed fields for filtering wherever possible.
Pitfall 7 — Misusing record-triggered flow trigger conditions
Choose the correct trigger type (before-save vs after-save). For fast field updates and low-latency changes, use before-save flows. For operations that need record Ids or related records, use after-save flows.
Pitfall 8 — Not versioning or documenting flows
Always create a new version when making changes, document the purpose and changes in the flow description, and maintain change logs. This helps rollback and auditing.
Pitfall 9 — Over-reliance on formula fields in Flow when a simple field or validation rule would do
Use the right tool — validation rules for simple validations, formula fields for calculated values. Avoid duplicating logic across Flow formulas and validation rules.
Pitfall 10 — Not testing with bulk and edge-case data
Test flows with multiple records, mixed profiles, and different data volumes. Include negative test cases and verify how flows behave with nulls and unexpected inputs.
Quick checklist before deploying a Flow
– Ensure bulk-safe design (no SOQL/DML in loops).
– Add Fault paths and logging.
– Use subflows for reusability.
– Pick before-save vs after-save correctly.
– Document versions and change notes.
– Test with bulk data and governor-limit scenarios.
Conclusion
Designing Salesforce Flows requires discipline: think about performance, reusability, error handling, and maintainability. Following these best practices reduces production incidents and makes automation easier to manage.








Leave a Reply