Sub topic 2
What a Workflow Rule does: criteria and actions
This chapter assumes you can navigate Setup, know the difference between objects, fields, and records, and can read a basic formula. You do not need to have built a Flow yet. The goal is to understand exactly what a Workflow Rule does, so you can rebuild it faithfully later.
The shape of a Workflow Rule
A Workflow Rule belongs to one object. It has three parts:
- Evaluation criteria. When Salesforce checks the rule.
- Rule criteria. The condition a record must meet.
- Actions. What happens when the condition is true. These are either immediate or time-dependent.
Salesforce evaluates the rule whenever a record of that object is saved. If the rule criteria are true, the actions run.
Evaluation criteria
The evaluation criteria decide how often a rule can fire for the same record. There are three options:
| Option | Behavior |
|---|---|
| Created | Runs only when the record is created. |
| Created, and every time it's edited | Runs on every save, whether or not any field changed. |
| Created, and any time it's edited to subsequently meet criteria | Runs on create, then only when the record changes from not meeting the criteria to meeting them. |
The third option is the most common source of migration mistakes. It has no setting named after it in Flow. You rebuild it by comparing the current record with its prior values.
Rule criteria
You define the rule criteria in one of two ways:
- Field filters. For example, Stage equals Closed Won.
- A formula. The rule fires when the formula returns true.
Workflow formulas have quirks that differ from flow formulas. Picklist fields need ISPICKVAL, and ISCHANGED checks whether a field changed.
Workflow Rule formula:
AND(ISPICKVAL(StageName, "Closed Won"), Amount > 100000)In a flow, the same logic uses TEXT() for the picklist. A later chapter covers that translation.
Actions
A rule can hold any mix of four action types.
| Action | What it does |
|---|---|
| Field update | Changes a field on the record, or on its parent in a few cases. |
| Email alert | Sends an email from a template to chosen recipients. |
| Task | Creates a task assigned to a user, role, or the record owner. |
| Outbound message | Sends a SOAP message to an external endpoint. |
Field updates are special. When one changes a value, Salesforce can re-evaluate the object's workflow rules once more. Rules set to "every time it's edited" can therefore fire twice in one save. Keep this in mind, because a migrated flow may not reproduce that second pass.
Immediate and time-dependent actions
Each rule has two action groups.
- Immediate actions run as part of the save.
- Time-dependent actions wait for a set time before or after a date field on the record, such as 7 days after Close Date. They are queued, and Salesforce re-checks the criteria before running them. If the record no longer meets the criteria, the queued actions are removed.
Time-dependent actions are not available on rules set to "every time it's edited". That restriction is why some orgs have several near-identical rules.
What to record for each rule
For every rule, write down the object, the evaluation criteria, the criteria logic, and each action with its timing. These notes become the specification for your flow.
Exercise
A rule uses "Created, and any time it's edited to subsequently meet criteria" with the criteria Stage = Closed Won. A user saves a Closed Won opportunity again without changing the stage. Do the actions run?
Show answer
No. The rule fires only when the record changes from not meeting the criteria to meeting them. The record already met the criteria, so the later save does not trigger the actions.