• abhis
  • 0 Points
  • Member since 2011

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1

I'm using a trigger to submit custom object records for approval as soon as they are created.  Here is the code that submits the record(s):



trigger modSubmitter on Modification__c (after Insert) { Approval.ProcessSubmitRequest[] reqs = new Approval.ProcessSubmitRequest[]{}; for(Modification__c m : Trigger.New){ if(m.Status__c!='Approved'){ Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setObjectId(m.id); reqs.add(req1); } } if(reqs.size()>0) Approval.ProcessResult[] result = Approval.process(reqs); }



 I then try inserting a record and it fails because an exception is thrown, error is "MANAGER_NOT_DEFINED".  All users involved in the process have managers defined in their user records... plus the approval process doesn't look at the manager field on any users anyhow... it just uses 'related user' lookup fields for all steps.


The API docs just say that this error means there is no manager for the approval process, which doesn't help much.  I scoured the Apex guides to see if there were more Approval methods available for somehow defining a "manager" for the request, but there is nothing.


Any ideas?