Labsco
github logo

salesforce-flow-design

βœ“ Officialβ˜… 36,202

by github Β· part of github/awesome-copilot

Salesforce Flow architecture decisions, flow type selection, bulk safety validation, and fault handling standards. Use this skill when designing or reviewing Record-Triggered, Screen, Autolaunched, Scheduled, or Platform Event flows to ensure correct type selection, no DML/Get Records in loops, proper fault connectors on all data-changing elements, and appropriate automation density checks before deployment.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup
🧩 One of 7 skills in the github/awesome-copilot package β€” works on its own, and pairs well with its siblings.

This is the playbook your agent receives when the skill activates β€” you don't need to read it to use the skill, but it's here to audit before installing.

Salesforce Flow Design and Validation

Apply these checks to every Flow you design, build, or review.

Step 1 β€” Confirm Flow Is the Right Tool

Before designing a Flow, verify that a lighter-weight declarative option cannot solve the problem:

RequirementBest tool
Calculate a field value with no side effectsFormula field
Prevent a bad record save with a user messageValidation rule
Sum or count child records on a parentRoll-up Summary field
Complex multi-object logic, callouts, or high volumeApex (Queueable / Batch) β€” not Flow
Everything elseFlow βœ“

If you are building a Flow that could be replaced by a formula field or validation rule, ask the user to confirm the requirement is genuinely more complex.

Step 2 β€” Select the Correct Flow Type

Use caseFlow typeKey constraint
Update a field on the same record before it is savedBefore-save Record-TriggeredCannot send emails, make callouts, or change related records
Create/update related records, emails, calloutsAfter-save Record-TriggeredRuns after commit β€” avoid recursion traps
Guide a user through a multi-step UI processScreen FlowCannot be triggered by a record event automatically
Reusable background logic called from another FlowAutolaunched (Subflow)Input/output variables define the contract
Logic invoked from Apex @InvocableMethodAutolaunched (Invocable)Must declare input/output variables
Time-based batch processingScheduled FlowRuns in batch context β€” respect governor limits
Respond to events (Platform Events / CDC)Platform Event–TriggeredRuns asynchronously β€” eventual consistency

Decision rule: choose before-save when you only need to change the triggering record's own fields. Move to after-save the moment you need to touch related records, send emails, or make callouts.

Step 3 β€” Bulk Safety Checklist

These patterns are governor limit failures at scale. Check for all of them before the Flow is activated.

DML in Loops β€” Automatic Fail

Loop element
  └── Create Records / Update Records / Delete Records  ← ❌ DML inside loop

Fix: collect records inside the loop into a collection variable, then run the DML element outside the loop.

Get Records in Loops β€” Automatic Fail

Loop element
  └── Get Records  ← ❌ SOQL inside loop

Fix: perform the Get Records query before the loop, then loop over the collection variable.

Correct Bulk Pattern

Get Records β€” collect all records in one query
└── Loop over the collection variable
    └── Decision / Assignment (no DML, no Get Records)
└── After the loop: Create/Update/Delete Records β€” one DML operation

Transform vs Loop

When the goal is reshaping a collection (e.g. mapping field values from one object to another), use the Transform element instead of a Loop + Assignment pattern. Transform is bulk-safe by design and produces cleaner Flow graphs.

Step 5 β€” Automation Density Check

Before deploying, verify there are no overlapping automations on the same object and trigger event:

  • Other active Record-Triggered Flows on the same Object + When to Run combination
  • Legacy Process Builder rules still active on the same object
  • Workflow Rules that fire on the same field changes
  • Apex triggers that also run on the same before insert / after update context

Overlapping automations can cause unexpected ordering, recursion, and governor limit failures. Document the automation inventory for the object before activating.

Step 6 β€” Screen Flow UX Guidelines

  • Every path through a Screen Flow must reach an End element β€” no orphan branches.
  • Provide a Back navigation option on multi-step flows unless back-navigation would corrupt data.
  • Use lightning-input and SLDS-compliant components for all user inputs β€” do not use HTML form elements.
  • Validate required inputs on the screen before the user can advance β€” use Flow validation rules on the screen.
  • Handle the Pause element if the flow may need to await user action across sessions.

Quick Reference β€” Flow Anti-Patterns Summary

Anti-patternRiskFix
DML element inside a LoopGovernor limit exceptionMove DML outside the loop
Get Records inside a LoopSOQL governor limit exceptionQuery before the loop
No fault connector on DML/email/callout elementUnhandled exception surfaced to userAdd fault path to every such element
Updating the triggering record in an after-save flow with no recursion guardInfinite trigger loopsAdd an entry condition or recursion guard variable
Looping directly on $Record collectionIncorrect behaviour at scaleAssign to a collection variable first, then loop
Process Builder still active alongside a new FlowDouble-execution, unexpected orderingDeactivate Process Builder before activating the Flow
Screen Flow with no End element on all branchesRuntime error or stuck userEnsure every branch resolves to an End element