salesforce-flow-design

bởi github

Các quyết định kiến trúc Salesforce Flow, lựa chọn loại flow, xác thực an toàn hàng loạt và tiêu chuẩn xử lý lỗi. Sử dụng kỹ năng này khi thiết kế hoặc xem xét…

npx skills add https://github.com/github/awesome-copilot --skill salesforce-flow-design

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 4 — Fault Path Requirements

Every element that can fail at runtime must have a fault connector. Flows without fault paths surface raw system errors to users.

Elements That Require Fault Connectors

  • Create Records
  • Update Records
  • Delete Records
  • Get Records (when accessing a required record that might not exist)
  • Send Email
  • HTTP Callout / External Service action
  • Apex action (invocable)
  • Subflow (if the subflow can throw a fault)

Fault Handler Pattern

Fault connector → Log Error (Create Records on a logging object or fire a Platform Event)
               → Screen element with user-friendly message (Screen Flows)
               → Stop / End element (Record-Triggered Flows)

Never connect a fault path back to the same element that faulted — this creates an infinite loop.

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.

Step 7 — Deployment Safety

Deploy as Draft    →   Test with 1 record   →   Test with 200+ records   →   Activate
  • Always deploy as Draft first and test thoroughly before activation.
  • For Record-Triggered Flows: test with the exact entry conditions (e.g. ISCHANGED(Status) — ensure the test data actually triggers the condition).
  • For Scheduled Flows: test with a small batch in a sandbox before enabling in production.
  • Check the Automation Density score for the object — more than 3 active automations on a single object increases order-of-execution risk.

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

Thêm skills từ github

console-rendering
github
Hướng dẫn sử dụng hệ thống kết xuất console dựa trên thẻ struct trong Go
official
acquire-codebase-knowledge
github
Sử dụng kỹ năng này khi người dùng yêu cầu rõ ràng để lập bản đồ, tài liệu hóa hoặc làm quen với một mã nguồn hiện có. Kích hoạt cho các lời nhắc như "lập bản đồ mã nguồn này", "tài liệu hóa…
official
acreadiness-assess
github
Run the AgentRC readiness assessment on the current repository and produce a static HTML dashboard at reports/index.html. Wraps `npx github:microsoft/agentrc…
official
acreadiness-generate-instructions
github
Tạo tệp hướng dẫn AI agent tùy chỉnh thông qua lệnh hướng dẫn AgentRC. Tạo ra tệp .github/copilot-instructions.md (mặc định, được khuyến nghị cho Copilot trong VS…)
official
acreadiness-policy
github
Giúp người dùng chọn, viết hoặc áp dụng chính sách AgentRC. Chính sách tùy chỉnh điểm sẵn sàng bằng cách tắt các kiểm tra không liên quan, ghi đè mức độ tác động/cấp độ, thiết lập…
official
add-educational-comments
github
Thêm các bình luận giáo dục vào các tệp mã để biến chúng thành tài liệu học tập hiệu quả. Điều chỉnh độ sâu giải thích và giọng điệu theo ba cấp độ kiến thức có thể cấu hình: sơ cấp, trung cấp và nâng cao. Tự động yêu cầu một tệp nếu không có tệp nào được cung cấp, với danh sách đánh số để chọn nhanh. Mở rộng tệp lên tới 125% chỉ bằng các bình luận giáo dục (giới hạn cứng: 400 dòng mới; 300 dòng cho tệp trên 1.000 dòng). Bảo toàn mã hóa tệp, kiểu thụt lề, tính đúng đắn cú pháp và...
official
adobe-illustrator-scripting
github
Viết, gỡ lỗi và tối ưu hóa các tập lệnh tự động hóa Adobe Illustrator bằng ExtendScript (JavaScript/JSX). Sử dụng khi tạo hoặc sửa đổi các tập lệnh thao tác…
official
agent-governance
github
Các chính sách khai báo, phân loại ý định và nhật ký kiểm toán để kiểm soát quyền truy cập và hành vi công cụ của tác nhân AI. Các chính sách quản trị có thể kết hợp xác định công cụ được phép/bị chặn, bộ lọc nội dung, giới hạn tốc độ và yêu cầu phê duyệt — được lưu trữ dưới dạng cấu hình, không phải mã. Phân loại ý định ngữ nghĩa phát hiện các lời nhắc nguy hiểm (rò rỉ dữ liệu, leo thang đặc quyền, tiêm lời nhắc) trước khi thực thi công cụ bằng tín hiệu dựa trên mẫu. Trình trang trí quản trị cấp công cụ thực thi các ch
official