I've got code to create and submit for approval a custom object. I'm running into the DML statement limit.

As far as I can see each record I submit for approval takes up a DML statement, but there's no option to submit in bulk.......

Am I missing something?


You can submit multiple Records for approval, sample code below.

List<Approval.ProcessSubmitRequest> requests = new List<Approval.ProcessSubmitRequest> ();
     for (Id oppId: opportunities) {
                    Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
                    req1.setComments('Submitting request for approval ');

      Approval.ProcessResult[] processResults = null;
                try {
                    processResults = Approval.process(requests, true)
    }catch (System.DmlException e) {
        System.debug('Exception Is ' + e.getMessage());
  • Thanks @techtrekker! Couldn't see this in the docs. Just a note that you need to create the variable requests, something like: list<Approval.ProcessSubmitRequest> requests = new list<Approval.ProcessSubmitRequest>(); – ChrisN Oct 12 '12 at 10:48
  • Absolutely, missed writing the declaration. – techtrekker Oct 12 '12 at 11:01
  • perhaps you could update your answer ;) – Daniel Blackhall Oct 12 '12 at 11:07
  • My thoughts exactly.... done ! :) – techtrekker Oct 12 '12 at 11:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.