Flow & Process Automation

Flow types, before-save vs after-save, building common automations and choosing Flow or Apex.

Admin 2 min readFlowAutomationApproval process

Flow is Salesforce's main declarative automation tool. Workflow Rules and Process Builder are retired for new automation — migrate them to Flow.

Flow types

TypeStarts whenExample
Record-triggeredA record is created/updated/deletedDefault a field, create a task
ScreenA user launches it (button, page, action)Guided wizard
Schedule-triggeredOn a scheduleNightly clean-up
AutolaunchedCalled by Apex, another flow, RESTReusable logic
Platform event–triggeredAn event is publishedReact 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 DMLpossible 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

  1. Decision: AnnualRevenue >= 1,000,000 → Hot; >= 100,000 → Warm; default → Cold.
  2. 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.

  1. 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 whenChoose Apex when
Logic is simple to moderateComplex logic, heavy data volumes
Admins will maintain itCallouts with complex parsing, advanced error handling
Field updates, records, emails, approvalsPrecise 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

  1. Before-save vs after-save flow?
  2. How do you avoid hitting limits in a flow loop? → No DML/queries inside loops; use collections.
  3. 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".
  4. When would you pick Apex over Flow?

Practice this