Salesforce Flow Design

Salesforce Flow Design

Guides design and review of Salesforce Flows: choosing the right flow type, bulk safety, fault handling and automation density checks before deployment.

Skill files1 file
SKILL.md136 lines
1
---
2
name: salesforce-flow-design
3
description: '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.'
4
---
5
6
# Salesforce Flow Design and Validation
7
8
Apply these checks to every Flow you design, build, or review.
9
10
## Step 1 — Confirm Flow Is the Right Tool
11
12
Before designing a Flow, verify that a lighter-weight declarative option cannot solve the problem:
13
14
| Requirement | Best tool |
15
|---|---|
16
| Calculate a field value with no side effects | Formula field |
17
| Prevent a bad record save with a user message | Validation rule |
18
| Sum or count child records on a parent | Roll-up Summary field |
19
| Complex multi-object logic, callouts, or high volume | Apex (Queueable / Batch) — not Flow |
20
| Everything else | Flow ✓ |
21
22
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.
23
24
## Step 2 — Select the Correct Flow Type
25
26
| Use case | Flow type | Key constraint |
27
|---|---|---|
28
| Update a field on the same record before it is saved | Before-save Record-Triggered | Cannot send emails, make callouts, or change related records |
29
| Create/update related records, emails, callouts | After-save Record-Triggered | Runs after commit — avoid recursion traps |
30
| Guide a user through a multi-step UI process | Screen Flow | Cannot be triggered by a record event automatically |
31
| Reusable background logic called from another Flow | Autolaunched (Subflow) | Input/output variables define the contract |
32
| Logic invoked from Apex `@InvocableMethod` | Autolaunched (Invocable) | Must declare input/output variables |
33
| Time-based batch processing | Scheduled Flow | Runs in batch context — respect governor limits |
34
| Respond to events (Platform Events / CDC) | Platform Event–Triggered | Runs asynchronously — eventual consistency |
35
36
**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.
37
38
## Step 3 — Bulk Safety Checklist
39
40
These patterns are governor limit failures at scale. Check for all of them before the Flow is activated.
41
42
### DML in Loops — Automatic Fail
43
44
```
45
Loop element
46
└── Create Records / Update Records / Delete Records ← ❌ DML inside loop
47
```
48
49
Fix: collect records inside the loop into a collection variable, then run the DML element **outside** the loop.
50
51
### Get Records in Loops — Automatic Fail
52
53
```
54
Loop element
55
└── Get Records ← ❌ SOQL inside loop
56
```
57
58
Fix: perform the Get Records query **before** the loop, then loop over the collection variable.
59
60
### Correct Bulk Pattern
61
62
```
63
Get Records — collect all records in one query
64
└── Loop over the collection variable
65
└── Decision / Assignment (no DML, no Get Records)
66
└── After the loop: Create/Update/Delete Records — one DML operation
67
```
68
69
### Transform vs Loop
70
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.
71
72
## Step 4 — Fault Path Requirements
73
74
Every element that can fail at runtime must have a fault connector. Flows without fault paths surface raw system errors to users.
75
76
### Elements That Require Fault Connectors
77
- Create Records
78
- Update Records
79
- Delete Records
80
- Get Records (when accessing a required record that might not exist)
81
- Send Email
82
- HTTP Callout / External Service action
83
- Apex action (invocable)
84
- Subflow (if the subflow can throw a fault)
85
86
### Fault Handler Pattern
87
```
88
Fault connector → Log Error (Create Records on a logging object or fire a Platform Event)
89
→ Screen element with user-friendly message (Screen Flows)
90
→ Stop / End element (Record-Triggered Flows)
91
```
92
93
Never connect a fault path back to the same element that faulted — this creates an infinite loop.
94
95
## Step 5 — Automation Density Check
96
97
Before deploying, verify there are no overlapping automations on the same object and trigger event:
98
99
- Other active Record-Triggered Flows on the same `Object` + `When to Run` combination
100
- Legacy Process Builder rules still active on the same object
101
- Workflow Rules that fire on the same field changes
102
- Apex triggers that also run on the same `before insert` / `after update` context
103
104
Overlapping automations can cause unexpected ordering, recursion, and governor limit failures. Document the automation inventory for the object before activating.
105
106
## Step 6 — Screen Flow UX Guidelines
107
108
- Every path through a Screen Flow must reach an **End** element — no orphan branches.
109
- Provide a **Back** navigation option on multi-step flows unless back-navigation would corrupt data.
110
- Use `lightning-input` and SLDS-compliant components for all user inputs — do not use HTML form elements.
111
- Validate required inputs on the screen before the user can advance — use Flow validation rules on the screen.
112
- Handle the **Pause** element if the flow may need to await user action across sessions.
113
114
## Step 7 — Deployment Safety
115
116
```
117
Deploy as Draft → Test with 1 record → Test with 200+ records → Activate
118
```
119
120
- Always deploy as **Draft** first and test thoroughly before activation.
121
- For Record-Triggered Flows: test with the exact entry conditions (e.g. `ISCHANGED(Status)` — ensure the test data actually triggers the condition).
122
- For Scheduled Flows: test with a small batch in a sandbox before enabling in production.
123
- Check the Automation Density score for the object — more than 3 active automations on a single object increases order-of-execution risk.
124
125
## Quick Reference — Flow Anti-Patterns Summary
126
127
| Anti-pattern | Risk | Fix |
128
|---|---|---|
129
| DML element inside a Loop | Governor limit exception | Move DML outside the loop |
130
| Get Records inside a Loop | SOQL governor limit exception | Query before the loop |
131
| No fault connector on DML/email/callout element | Unhandled exception surfaced to user | Add fault path to every such element |
132
| Updating the triggering record in an after-save flow with no recursion guard | Infinite trigger loops | Add an entry condition or recursion guard variable |
133
| Looping directly on `$Record` collection | Incorrect behaviour at scale | Assign to a collection variable first, then loop |
134
| Process Builder still active alongside a new Flow | Double-execution, unexpected ordering | Deactivate Process Builder before activating the Flow |
135
| Screen Flow with no End element on all branches | Runtime error or stuck user | Ensure every branch resolves to an End element |
136

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 13,417 prompts

More by @OpenSourceBuffGuy

See all
Young women walk a lively Korean night market prompt image

Young women walk a lively Korean night market

Generates a realistic documentary-style video of a young Korean woman walking a night market, choosing grilled food and eating it, with ambient audio and a strict negative list.

video-prompt, seedance, vlog, documentary, handheld, lip-sync, negative-prompt, cinematic, photorealistic, night-scene, widescreen, camera-movement, korea, travel, cooking, restaurants, structured-output, long-form, for-content-creators, for-filmmakers, cityscape, single-take, scene-transitions, warm-lighting

Selfie with chibi self painting his cheek prompt image

Selfie with chibi self painting his cheek

Makes a playful selfie of a paint-splattered man beside an easel, where a 3D chibi version of him painted on the canvas reaches out and paints his cheek.

image-prompt, reference-image, face-reference, selfie, portrait, chibi, gpt-image, photorealistic, 3d-render, cartoon, cozy, close-up, natural-light, vibrant-colors, painting, man, text-rendering, structured-output, for-content-creators, for-artists, humorous, whimsical, medium-shot, playful

GTA VI Character Reveal Poster From a Photo prompt image

GTA VI Character Reveal Poster From a Photo

Turns an uploaded photo into a Grand Theft Auto VI style character reveal poster with a loading bar and a small original-photo inset, keeping the person's face and hair.

image-prompt, json-prompt, reference-image, face-reference, style-transfer, guardrails, structured-output, gta-style, video-games, character-design, poster, game-assets, digital-art, illustration, cinematic, vibrant-colors, golden-hour, portrait, long-form, gpt-image, chatgpt, for-artists, placeholders

Reviews

Loading reviews…

Discussion

Loading comments…