0

I have an approval process in an after insert trigger. My question is will this work as its is not working atm. But if i delete the apex approval process. let the custom object get inserted and then manually submit for approval then it submits, so all values (entry req) are correct.

This is the apex process

 for (Data_Agreement__c d : DA) {    
      if (d.status__c == 'Draft') {
        system.debug('approval trig 2' + d.id);
   
        Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
        req1.setComments('Submitting request for approval.');
        req1.setObjectId(d.id);
        req1.setSubmitterId(d.Owner.Id);
        req1.setProcessDefinitionNameOrId('DAApprovalProcess_Process');
         req1.setSkipEntryCriteria(false);
        Approval.ProcessResult result = Approval.process(req1);
      }

Also the custom object that I have created is a cloned object (the original object would have already had an approval process on it) which I though could have caused an issue, but again if i submit the ap manually it works so cab't be that. Any ideas?

1 Answer 1

1

I got it:

req1.setProcessDefinitionNameOrId('DAApprovalProcess_Process');

has to be name of the approval process not a random string

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .