I get the below error on some opps not all but some and I have no clue why. Any help would be great
"OpportunitySubmitForApproval2: 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.OpportunitySubmitForApproval2: line 15, column 1"
Here is my code
Trigger OpportunitySubmitForApproval2 on Opportunity (after update) {
for (Opportunity opp : Trigger.new){
if (opp.Stagename =='Sent To Accounting'){
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval.');
req.setObjectId(opp.Id);
// submit the approval request for processing
Approval.ProcessResult result = Approval.process(req);
// display if the reqeust was successful
System.debug('Submitted for approval successfully: '+result.isSuccess());
}
}
}