You need to sign in to do that
Don't have an account?
Invoking approval process from apex trigger
Hi,
I am encountering the following error when trying to invoke an approval process from a trigger.
changeAmounts: execution of AfterUpdate caused by: System.DmlException: Process failed. First exception on row 0; first error: ALREADY_IN_PROCESS, Cannot submit object already in process.: Trigger.changeAmounts: line 11, column 41
Here is the trigger code. I have tried several variations always with the same result. I have confirmed there is not an active approval process for the record.
trigger changeAmounts on Opportunity (after update) { Opportunity opp; opp = Trigger.old[0]; if (Trigger.old[0].Amount <> Trigger.new[0].Amount) { Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('Submitting request for approval.'); req1.setObjectId(opp.id); Approval.ProcessResult result1 = Approval.process(req1); } }
Any help is appreciated.
Thanks.
Dear kevin,
Iam facing the same issues, Can you please share your ideas or you having any valid suggestion for me.
Best Regards,
Ganesh
you are missing setNextApproverIds method.
Also check that opp.id is not null.
check for reference
http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=24909&query.id=292664#M24909
http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=14854&query.id=292664#M14854