Sub topic 6
Handling Multiple Approvers
This chapter covers what happens when an approval step names more than one approver. It assumes you know how to create an approval process, define steps, and choose approvers (users, queues, related users) from the earlier chapters. For the Apex example you also need basic Apex and SOQL.
The decision in one place
When a step resolves to several approvers, Salesforce asks you to choose how to treat them. This setting appears in the step wizard when you select more than one approver, or when you select a related user field that can resolve to several people.
There are two choices:
- Require UNANIMOUS approval from all selected approvers. Every approver must approve for the step to pass. If any approver rejects, the step is rejected.
- Approve or reject based on the FIRST response. The first approver to act decides the outcome of the step. The other approvers' work items are removed.
The choice applies to the step, not the whole process. Different steps in the same process can use different rules.
How each rule behaves at run time
Unanimous
With the unanimous rule, Salesforce creates one pending work item for each approver when the step starts. Each approver sees the request in their own list and can act independently.
- The step is approved only after all work items are approved.
- A single rejection rejects the step immediately. Work items from other approvers that are still pending are removed, so those people cannot act on a request that is already decided.
- Approvers do not need to act in any order. Each action is recorded as its own step in the history.
First response
With the first-response rule, every approver also gets a work item. The first response, approval or rejection, ends the step.
- If the first response is an approval, the step is approved and the process moves on.
- If the first response is a rejection, the step is rejected and the rejection actions run.
- The remaining work items disappear. A slower approver who opens the request finds nothing to act on.
Comparing the rules
| Aspect | Unanimous | First response |
|---|---|---|
| Who decides | All approvers together | Whoever acts first |
| Effect of one approval | Step keeps waiting for the others | Step approved immediately |
| Effect of one rejection | Step rejected immediately | Step rejected immediately |
| Typical use | Legal and finance sign-off where everyone must agree | Shared workload where any one qualified person can decide |
| Delay risk | Highest, one slow approver blocks the step | Lowest |
Queues are a special case
A queue counts as a single approver, even though many users belong to it. When a step assigns the request to a queue, Salesforce creates one work item that is owned by the queue. Any queue member can open it and act, and the first person to respond decides it.
This has a consequence people often miss. If you select a queue and one individual user in the same step, and choose unanimous, you have two approvers: the queue and the user. You need one response from a queue member and one from the user. You do not need every queue member to approve.
If you want every member of a group to approve, you cannot use a queue for that. Name the people individually, or use a related-user field that resolves to each of them.
Related users and hierarchy
A related-user approver, such as the record owner's manager, resolves to a single user at submission. Two common cases produce several approvers:
- You list more than one related user, for example the manager and an account owner, in the same step.
- You combine a related user with named users.
Each resolves to a person, and the multi-approver rule applies to the full set.
If a related user field is empty, for example the submitter has no manager, the step cannot assign an approver. Salesforce then falls back to the setting you chose for that step, such as moving to the next step or showing an error. Check the manager field is populated on test users, or the submission will not behave as you expect.
If the same person appears more than once in a step, for example as a named user and as the manager, they receive only one work item.
Step-level design patterns
You can combine the rules with several steps to build more specific approval paths.
- Sequential sign-off. Use separate steps, each with one approver. Step 1 is the manager, step 2 is finance. This is slower but gives a clear order, and each step has its own criteria and actions.
- Parallel sign-off. One step with several approvers and the unanimous rule. All approvers see the request at once, so it finishes faster than the sequential pattern.
- Any-one-of sign-off. One step with a queue or several users and the first-response rule. Use it for a pool of equally qualified reviewers.
- Parallel groups in sequence. Step 1 is unanimous across two legal reviewers, step 2 is first response across a finance queue. Mix the rules as the business requires.
Because the unanimous rule runs approvers in parallel, you cannot enforce an order between them within a single step. If order matters, use separate steps.
Recall, reassignment, and delegation
Several features interact with multiple approvers.
- Reassignment. If the process allows it, an approver can reassign their work item to another user. The new user takes that approver's place, and the step rule is evaluated the same way.
- Delegated approvers. If an approver has a delegated approver set on their user record, the delegate can respond for them. A response from a delegate counts as a response from that approver.
- Recall. If the submitter, or an administrator, recalls the request, all pending work items for the step are removed and the recall actions run.
Seeing the work items in Apex
Each approver's pending request is a ProcessInstanceWorkitem. You can query them to see who still has to respond. This shows the unanimous rule clearly, because several rows exist at once for the same instance.
Id opportunityId = '006000000000001AAA'; // replace with a real Opportunity Id
List<ProcessInstanceWorkitem> pending = [
SELECT Id, ActorId, Actor.Name, ProcessInstance.Status
FROM ProcessInstanceWorkitem
WHERE ProcessInstance.TargetObjectId = :opportunityId
AND ProcessInstance.Status = 'Pending'
];
System.debug('Pending approvers: ' + pending.size());
for (ProcessInstanceWorkitem w : pending) {
System.debug(w.Actor.Name + ' has not responded yet.');
}Under the unanimous rule, the list shrinks as each person approves. Under first response, it drops to zero after the first action. For a queue, ActorId holds the queue's Id, so Actor.Name shows the queue name rather than a person.
To approve one of these items from code, use the Approval.ProcessWorkitemRequest pattern shown in the Apex chapter. Process each work item separately, because each belongs to a different approver.
Common mistakes
- Expecting a queue to mean everyone. A queue is one approver. Use individual users when all must agree.
- Choosing unanimous when you want speed. One absent approver blocks the step. If any qualified person can decide, use first response.
- Assuming a rejection waits for others. Under both rules, one rejection ends the step.
- Leaving related-user fields empty. A missing manager leaves the step without an approver.
- Relying on order within one step. Approvers in the same step act in parallel.
Exercises
Exercise
A step lists three named users and the rule is "unanimous." Two approve, and the third rejects. What is the state of the step, and what happens to any work items still pending?
Show answer
The step is rejected. One rejection ends a unanimous step immediately, and any work items that are still pending are removed. The rejection actions then run.
Exercise
A step assigns the request to the "Finance Reviewers" queue (ten members) and to the CFO as a named user, using the unanimous rule. How many responses does the step need to be approved?
Show answer
Two. The queue counts as one approver, so one queue member's approval satisfies it, and the CFO's approval is the second. The queue's ten members do not each need to approve.
Exercise
Which Apex query shows who has not yet responded to a request for a given Opportunity, and why does the result differ between the unanimous and first-response rules?
Show answer
Query ProcessInstanceWorkitem filtered by ProcessInstance.TargetObjectId and ProcessInstance.Status = 'Pending'. Under the unanimous rule, one row exists per approver and the rows disappear as each person approves. Under first response, all rows are removed once the first approver acts.