• Radek Matusiak
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

I am trying this code to assign multiple approvers to an existing approval process

 

Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();req1.

 

setComments('Submitting request for approval.');

 

req1.setObjectId(theId);

 

req1.setNextApproverIds(new Id[] {'00590000000OYw5', '00590000000OYw5'});

 

 Approval.ProcessResult result = Approval.process(req1);

 

but its giving exception that the required field missing at line

 

 Approval.ProcessResult result = Approval.process(req1);

 

Please help me out. How to assign multiple User ids as approvers to the approval process but only through apex code

 

Thanks

Hello.

I have a trigger which creates Approval Requests.  I have the following block of code:

Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();

req1.setComments('Submitting request for approval.');
req1.setObjectId(newOpp.Id);
List<Id> nextAppIdList = new List<Id>();
nextAppIdList.add('00580000001pucY');
nextAppIdList.add('00580000001pucxAAA');
req1.setNextApproverIds(nextAppIdList);
//Submit the approval request for the solution
Approval.ProcessResult result = Approval.process(req1);

Note that there are multiple Approver Ids in the setNextApproverIds() call…

So if I run the code above, I get the following error:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger opportunityApprovalTrigger caused an unexpected exception, contact your administrator: opportunityApprovalTrigger: execution of AfterUpdate caused by: System.DmlException: Process failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, missing required field: []: Trigger.opportunityApprovalTrigger: line 61, column 45

Note that line 61 is: Approval.ProcessResult result = Approval.process(req1);

However, if I change the code so that I’m only submitting single approver, it works perfectly.  What am I doing wrong?

Thanks
Chris