1

I'm trying to change the approvers for an approval process via Apex. Ideally I want to dynamically set 2 unanimous approvers through code, but I can't figure it out.

I have the following code:

 public static void submitSplitApproval(Id recordId, List<Id> approverIds){

    approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
    req1.setComments('Submitting request for approval.');
    req1.setObjectId(recordId);
    Id approver = approverIds[0];
    req1.setNextApproverIds(new Id[] {approver});
    System.Debug(req1.getNextApproverIds());
    approval.ProcessResult result = Approval.process(req1);

}

I have lifted the bulk of the code from this answer here.

System.Debug displays the expected user ID, but once it's submitted and I browse to the record it's still showing the old approver. Is there a way to add 2 unanimous approvers dynamically via Apex?

Thanks for your help.

4
  • Just curious, where is the second approver?
    – Adrian Larson
    Jul 22 '16 at 14:45
  • @AdrianLarson I'm passing a list of approverIds to the method, but I figured I'd try and get one approver updated and working beforehand. Jul 22 '16 at 14:52
  • Is this the same issue mentioned here salesforce.stackexchange.com/questions/9049/… Jul 26 '16 at 12:46
  • Similar, but I'm more interested in trying to chain the steps together in Apex.
    – user24634
    Jul 29 '16 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.