Scenario
- custom object X that needs several approvals
- custom object where the approval routings are defined. (so to which approvers does the system need to send the object depending on a stage of the custom object X)
- several actual approval processes where for each of them, the approvers are set to "manually selected". Each of these approvals also have specific "final approval" and "final rejection" actions
- each approval process should work in a unanimous approval way, meaning that it's either all approvers that approve or that approval should be rejected
What is OK so far
Since I need to get the approval entities dynamically from my approval routing object, I needed to work with apex to submit the approvals. I quickly noticed that the setNextApproverIds didn't except just multiple user ID's but only one... I still find this über-strange but OK... I found this post which sort of does the trick, at least part of it.
Apex approval process that requires unanimous approval from multiple approvers
The problem
The problem however with this is that working this way, the "final approval" and "final rejection" action would fire immediately as soon as only 1 of the approvers would take action. This because instead of having 1 approval instance with multiple approvers, you just have 1 approval instance per approver...
The question
- Is there really no way through apex to do a unanimous approval exactly like it would work through the usual approval processes?
- If the answer to 1 is no, how to correctly handle these final approval / rejection actions? This, also knowing that we can have multiple approval processes on the same record.