Sub topic 4
Defining Approval Steps
This chapter covers how to define the steps of a Salesforce approval process. It assumes you know what entry criteria are and how to create an approval process in Setup. It also assumes you are comfortable with formula syntax and with users, roles, and queues. Choosing approvers gets only a brief mention here, because the next chapter covers it in detail.
What a step is
An approval step is one stage of the approval chain. Each step answers three questions:
- Which records does this step apply to? This is the step criteria.
- Who approves? This is the approver definition.
- What happens if the record is not approved at this step? This is the rejection behavior.
When a record is submitted, Salesforce evaluates the steps in order. The first step the record qualifies for becomes its current step. When that step is approved, the process moves on to the next step.
Approval step order is fixed by a number. You can reorder steps from the process detail page, but only before you activate the process. Once the process is active, you cannot add, remove, or reorder steps. To change them, you must deactivate the process, which is only possible when no records are pending in it, or clone it as a new version.
Step 1 is special
The first step is the only one that can be set up to run for every record that enters the process. Entry criteria already filter records at the door, so the first step usually does not need its own criteria. When you create the first step, you choose how it should treat records.
For steps after the first, you have three choices for the step criteria.
| Option | What it does |
|---|---|
| All records should enter this step | Every record that reaches this step goes through it. |
| Enter this step if the following | Only records that match your criteria or formula enter this step. |
| Enter this step if the following, else... | Same as above, with an extra choice for records that do not match. |
For the second and third options you can use filter criteria, such as Amount > 50000, or a formula that returns true or false. Use a formula when you need cross-object references, AND/OR combinations, or functions such as ISPICKVAL.
What happens when a record does not match a step
When a record does not meet the criteria for a step, you choose one of two behaviors. They are the most common source of confusion in step design.
- Approve the record. The record is treated as approved and the process ends, so the final approval actions run. Use this when the step is the last one that could apply. A record with a small amount might need only a manager, so a later step for directors does not apply to it.
- Reject the record. The record is rejected and the final rejection actions run. Use this when a record that fails the criteria should never be approved by this process.
- Go to the next step. On the first step, the "else" choice also offers to skip to the next step. Use this when later steps have criteria of their own.
Salesforce shows the "else" options only when you pick the criteria-based choice. They apply to the step that the record fails, not to the step before it.
Rejection behavior within a step
Separately from criteria, each step has its own rejection behavior. It applies when an approver rejects the record at that step. You choose one of two behaviors.
- Final Rejection. The whole request is rejected, the record is unlocked (usually), and the final rejection actions run.
- Go back to the previous approver. This option is available only from step 2 onward. The request returns to the approver of the previous step, who can then approve again or reject. If the previous approver rejects, that step's own rejection behavior applies.
The second option does not mean the previous approver's work is erased. It means the request is sent back to that person's queue as a new work item. Plan for this in your notifications, because that approver receives another request.
Step actions
Each step can have its own actions that run when the step is approved or rejected. Approval actions are covered in a later chapter. For step design, you only need to know that the actions on a step run in addition to the process-level actions. For example, a step-level email alert might tell the finance team that the manager has approved, while the final approval action updates the stage field.
Worked example: a discount approval
Suppose Opportunities with a discount need approval. The business rules are:
- Discounts up to 10% need no approval.
- Discounts from 10% up to 25% need the sales manager.
- Discounts of 25% or more need the sales manager and then the finance director.
Entry criteria handle the first rule. Set them to Discount_Percent__c >= 10 so smaller discounts never enter the process. Then define two steps.
Step 1: Manager approval
- Step criteria: all records should enter this step.
- Approver: the user's manager, from the standard Manager hierarchy field.
- Rejection behavior: Final Rejection.
Step 2: Finance approval
- Step criteria:
Discount_Percent__c >= 25, using a formula. - If criteria are not met: approve the record.
- Approver: the Finance Directors queue.
- Rejection behavior: Final Rejection.
Trace three records through this design.
| Discount | Path | Outcome |
|---|---|---|
| 5% | Does not meet entry criteria | Cannot be submitted |
| 15% | Step 1 approved, step 2 skipped | Final approval after the manager |
| 30% | Step 1 approved, then step 2 approved | Final approval after the director |
Notice that step 2 uses "approve the record" for non-matching records. If you chose "reject the record" instead, every 15% discount would be rejected after the manager approved it. That is a common bug.
// Reading the current step of a pending request
ProcessInstance pi = [
SELECT Id, Status
FROM ProcessInstance
WHERE TargetObjectId = :opportunityId
AND Status = 'Pending'
LIMIT 1
];
System.debug('Pending instance: ' + pi.Id);Edge cases to plan for
- Field values change while pending. Step criteria are evaluated when the record reaches the step, not only at submission. If the record is locked, users cannot edit it, but an administrator or an automation that bypasses the lock can. A change to
Discount_Percent__cafter step 1 can therefore change whether step 2 applies. Keep the fields that drive step criteria out of reach of automation while the record is pending. - Blank values in formulas. A comparison against a blank field may evaluate in a way you do not expect. Wrap such fields in
BLANKVALUE()orNULLVALUE()so a missing value follows the path you choose. - Order matters. Put the most restrictive steps later. If you place a step with an exclusive criterion first, records that do not match it will fall through to the "else" behavior and may be rejected unexpectedly.
- Active processes are locked in. Because you cannot edit steps in an active process, test in a sandbox and clone the process into a new version when the rules change. Records already pending stay on the old version.
- Step count. A process can have up to 30 steps. Most designs need far fewer. If you need many conditional branches, consider several processes with different entry criteria, or a different tool, which a later chapter discusses.
Common mistakes
- Choosing "reject the record" for non-matching records on a step that only some records need.
- Using "go back to the previous approver" on a process where steps have different approvers and nobody expects the extra request.
- Putting a filter on step 1 that is already covered by entry criteria, which hides the real reason a record was rejected.
- Editing an active process in place and expecting pending records to follow the new steps.
- Writing step formulas that depend on fields a user can change after submission.
Exercise
An approval process has two steps. Step 1 sends every record to the manager. Step 2 has the criteria Amount > 100000 and goes to the CFO. For step 2, you chose "reject the record" for records that do not match. A manager approves an opportunity with an amount of 60,000. What happens, and how do you fix the design?
Show answer
The record does not meet the step 2 criteria, so the "reject the record" setting applies and the opportunity is rejected even though the manager approved it. Change the non-matching behavior on step 2 to "approve the record". Then amounts of 100,000 or less get final approval after the manager, and larger amounts continue to the CFO.
Exercise
Why can't you add a third step to an active approval process, and what is the safe way to make the change?
Show answer
Salesforce does not allow steps to be added, removed, or reordered in an active process. Clone the process, add the step in the new version, test it in a sandbox, then deactivate the old version once no records are pending and activate the new one.