Flow & Process Automation
Flow types, before-save vs after-save, building common automations and choosing Flow or Apex.
Flow is Salesforce's main declarative automation tool. Workflow Rules and Process Builder are retired for new automation — migrate them to Flow.
Flow types
| Type | Starts when | Example |
|---|---|---|
| Record-triggered | A record is created/updated/deleted | Default a field, create a task |
| Screen | A user launches it (button, page, action) | Guided wizard |
| Schedule-triggered | On a schedule | Nightly clean-up |
| Autolaunched | Called by Apex, another flow, REST | Reusable logic |
| Platform event–triggered | An event is published | React to integrations |
Record-triggered: before-save vs after-save
| Fast Field Updates (before save) | Actions and Related Records (after save) | |
|---|---|---|
| Updates the triggering record | ✅ very fast, no extra DML | possible but costs a DML + re-save |
| Create/update other records | ❌ | ✅ |
| Send emails, call subflows/actions | ❌ | ✅ |
| Record Id available on create | ❌ | ✅ |
Example 1 — default a Rating (before-save)
Object: Account · Trigger: created · Optimize for: Fast Field Updates
- Decision:
AnnualRevenue >= 1,000,000→ Hot;>= 100,000→ Warm; default → Cold. - Assignment:
{!$Record.Rating}= the chosen value.
No Update Records element is needed — changes to $Record are saved automatically.
Example 2 — mark the Account a Customer when an Opportunity is won (after-save)
Object: Opportunity · Trigger: updated · Entry condition: StageName = Closed Won · Only when a record is updated to meet the condition.
- Update Records: Account where
Id = {!$Record.AccountId}→Type = Customer.
The "only when updated to meet the condition" option is the declarative version of comparing Trigger.old and Trigger.new.
Best practices
- Keep one or few record-triggered flows per object and use entry conditions and trigger order.
- Never put Get/Update/Create Records inside a Loop — collect into a collection variable and update once (same bulkification rule as Apex).
- Add fault paths to handle errors.
- Use subflows for reusable logic.
Flow or Apex?
| Choose Flow when | Choose Apex when |
|---|---|
| Logic is simple to moderate | Complex logic, heavy data volumes |
| Admins will maintain it | Callouts with complex parsing, advanced error handling |
| Field updates, records, emails, approvals | Precise control of transactions, unit tests, reuse in APIs |
Approval processes
Multi-step sign-off (e.g. discounts > 20%) with entry criteria, approvers (manager, queue, user), approval/rejection actions and record locking.
Interview questions
- Before-save vs after-save flow?
- How do you avoid hitting limits in a flow loop? → No DML/queries inside loops; use collections.
- How do you make a flow run only when a field changes to a value? → "Only when a record is updated to meet the condition requirements".
- When would you pick Apex over Flow?