Sub topic 1
The Salesforce automation toolbox at a glance
This chapter maps the main Salesforce automation tools and the kind of problem each one fits. Later chapters cover each tool in depth. Here you learn what exists, how the tools differ, and how to sort a requirement into the right group.
Prerequisites
This chapter assumes you already know:
- The basic Salesforce data model: objects, fields, records, and relationships such as lookup and master-detail.
- How to find your way around Setup and the Object Manager.
- Common business processes, such as lead conversion and opportunity stages.
- Optionally, how to read simple Apex or SOQL. You do not need to write either to follow this chapter.
What "automation" means on the platform
Automation is any logic that runs without a user doing the work by hand. It might set a field, create a task, send an email, require a manager's approval, or update thousands of records overnight. Salesforce offers several tools for this, and they differ in three ways:
- What starts them. A record save, a user clicking a button, a schedule, or a request for approval.
- How you build them. Point-and-click configuration (called declarative) or code (Apex).
- How much they can handle. Each tool has its own limits on volume and complexity.
Picking well matters because automation is hard to remove once people depend on it. A tool that is too weak forces a rewrite. A tool that is too heavy leaves you with code that an admin cannot maintain.
The toolbox
The tools fall into four groups.
Declarative field and data rules
These are the simplest tools. They live on the object and need no flow or code.
- Validation rules block a save when a formula says the data is wrong.
- Formula fields calculate a value from other fields every time it is read. Nothing is stored or updated.
- Roll-up summary fields calculate a count, sum, minimum, or maximum over child records. They work only on the master side of a master-detail relationship.
Flow
Flow Builder is the main declarative automation tool today. One tool covers several flow types:
- Record-triggered flows run when a record is created, updated, or deleted. They can be before-save (fast, changes the triggering record) or after-save (can touch related records and take actions).
- Screen flows show screens to a user and collect input step by step.
- Scheduled flows run on a set schedule against a batch of records.
- Autolaunched flows have no trigger of their own. Another flow, Apex, or a button starts them.
- Flow Orchestrator coordinates multi-step, multi-user processes made of several flows.
Approval processes
An approval process routes a record to one or more approvers and records their decision. It can lock the record while approval is pending and run actions when the request is approved or rejected. Use it when the requirement is a formal sign-off.
Apex
Apex is Salesforce's server-side programming language.
- Apex triggers run before or after a record is saved, with full programmatic control.
- Asynchronous Apex (Queueable, Batch, and Scheduled Apex) runs work outside the user's transaction. It suits slow, long-running, or high-volume jobs.
Legacy tools
Workflow Rules and Process Builder were the main declarative tools before Flow. Salesforce has retired them in favor of Flow, so you should not build anything new with them. You will still meet them in older orgs, and a later chapter covers how to migrate them.
How the tools compare
| Tool | Starts when | Built with | Typical use |
|---|---|---|---|
| Validation rule | A record is saved | Formula | Reject bad data |
| Formula field | A record is read | Formula | Derived display value |
| Roll-up summary field | Child records change | Configuration | Totals over child records |
| Record-triggered flow | A record is created, updated, or deleted | Flow Builder | Field updates, related records, emails |
| Screen flow | A user launches it | Flow Builder | Guided data entry |
| Scheduled flow | A set time | Flow Builder | Nightly or weekly batch updates |
| Approval process | A user or automation submits a record | Configuration | Manager sign-off |
| Apex trigger | A record is saved | Code | Complex logic, integrations |
| Asynchronous Apex | Enqueued by code or scheduled | Code | Large or slow jobs |
A picture of the trigger sources
Each tool starts from a different event. This diagram groups the tools by what starts them.
Notice that several tools can respond to the same event. A record save can fire a validation rule, a flow, and an Apex trigger on one object. That overlap is the source of most automation bugs, and it is why later chapters spend time on the order of execution and on avoiding conflicts.
Two tools for the same job
The same requirement can often be met by more than one tool. Take "set Rating to Hot when annual revenue is at least 1,000,000." You can build it as a before-save record-triggered flow with no code. You can also write it as an Apex trigger:
trigger AccountTrigger on Account (before insert, before update) {
for (Account acc : Trigger.new) {
if (acc.AnnualRevenue != null && acc.AnnualRevenue >= 1000000) {
acc.Rating = 'Hot';
}
}
}This trigger is bulk-safe. It loops over Trigger.new, which holds every record in the save, and it needs no DML statement because a before trigger changes the records already being saved. The flow version does the same thing with less maintenance burden for an admin. Both work, so the question is not "can it be done?" but "which tool is the simplest one that will keep working?" The next chapter turns that question into a principle.
Why limits shape the choice
Every tool runs under limits. Apex runs under governor limits, which cap things such as the number of SOQL queries and DML statements in one transaction. Flows run under the same transaction limits when they execute, so a poorly built flow can fail on large data loads just as bad code can. Asynchronous Apex gets a fresh set of limits in its own transaction. This is one reason it exists:
public class RecalculateRatingJob implements Queueable {
private List<Id> accountIds;
public RecalculateRatingJob(List<Id> accountIds) {
this.accountIds = accountIds;
}
public void execute(QueueableContext context) {
List<Account> accounts = [SELECT Id, AnnualRevenue FROM Account WHERE Id IN :accountIds];
for (Account acc : accounts) {
acc.Rating = (acc.AnnualRevenue != null && acc.AnnualRevenue >= 1000000) ? 'Hot' : 'Warm';
}
update accounts;
}
}
// Enqueue from Apex, for example inside a trigger handler:
// System.enqueueJob(new RecalculateRatingJob(accountIdList));The job uses one query and one DML statement for the whole list, so it stays well inside its limits however many records it receives.
A first sorting pass
You will build a full decision framework in a later chapter. For now, this short checklist runs from the simplest tool to the most complex. Stop at the first step that fits.
1. Can a validation rule, formula field or roll-up summary field solve it? Use that.
2. Does it run when a record is created or updated? Try a record-triggered flow (before-save to change the same record, after-save for related records or actions).
3. Does a user need guided steps? Use a screen flow.
4. Does it run on a schedule? Use a scheduled flow, or scheduled Apex for very large volumes.
5. Does it need formal sign-off? Use an approval process, or Flow Orchestrator for multi-step work across users.
6. Does it need complex logic, very large volumes, or something Flow cannot do? Use Apex, and move slow work to asynchronous Apex.Common mistakes at this stage
- Treating "automation" as one tool. Teams that say "we use Flow for everything" often misuse it for sign-offs or very large batch jobs.
- Building new work on Workflow Rules or Process Builder. These are legacy. New work belongs in Flow.
- Ignoring overlap. Two tools updating the same field on the same object will race, and the last one to run wins.
- Reaching for Apex first. Code is justified, but only after a simpler tool has been ruled out.
Exercises
Exercise
A requirement says: "When an opportunity moves to Closed Won, a director must approve any discount over 20% before the deal is finalized." Which tool group fits best, and why?
Show answer
An approval process. The requirement is a formal sign-off from a specific approver, which is what approval processes are designed for. A record-triggered flow could start the submission, but the approval routing and decision record belong in the approval process.
Exercise
Name two tools that can respond to the same record save, and explain why that matters.
Show answer
For example, a record-triggered flow and an Apex trigger on the same object. Both run when the record is saved, so they can update the same field or repeat work. This overlap is why you need to understand the order of execution and plan how automations coexist on an object.
Exercise
Why does the Apex trigger in this chapter need no update statement to set Rating?
Show answer
It is a before trigger. In a before trigger, the records in Trigger.new have not yet been written to the database, so changes made to them are saved with the original operation. An extra DML statement would be unnecessary.