function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kevinp211Kevinp211 

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.

 

 

GanuGanu

Dear kevin,

 

Iam facing the same issues, Can you please share your ideas or you having any valid suggestion for me.

 

 

Best Regards,

Ganesh

vikramn3233vikramn3233
Someone please help, even I have the same question.
NaishadhNaishadh

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 

Message Edited by Naishadh on 03-17-2010 05:58 AM