I have an approval process with three steps, all of which are set to Assigned Approver = Manually Chosen. When a user applies for approval, I would like the Apex code to determine who the three approvers are. However, I do not see an opportunity to look into the approved application.
If I submit the claim using Apex Using Approval.process()
, I can set the initial (and only the initial) ProcessSubmitRequest.setNextApproverIds()
using ProcessSubmitRequest.setNextApproverIds()
. This call makes you think that you can specify several approvers, since it accepts an array of identifiers, but the array can have only one element, or the error execution time.
Once I know what the first approver response is, I can use Apex to send the response and, again, set the next next ProcessWorkitemRequest
passing the ProcessWorkitemRequest
instance to Approval.process()
. It is important to note that the approver does not have to approve through the standard interface. Instead, they should do something that calls the Apex code so that we can determine who the next should be. A trigger for the object in question or a custom button + VF page can be used to call Apex.
My main question is: how can I make sure that the user is not using the standard approval buttons? They appear in the list of relevant claims and on the Salesforce main screen. It may be in other places. Again, if they use the standard submit and approval buttons, I have no way to connect to install the next approver.
source share