+ Start a Discussion
c_r_carvalhoc_r_carvalho 

Approve Actions not working

I'm trying to do a custom approve method:

List< ProcessInstanceWorkitem > listAprovacoes = [Select Id,ProcessInstanceId, OriginalActorId, CreatedDate, CreatedById,      ActorId  FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: guia.Id ORDER BY CreatedDate desc limit 1];
ProcessInstanceWorkitem lWorkItem;
lWorkItem = listAprovacoes[0];
Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
req.setComments( parecerTecnico.Justificativa__c );
req.setAction('Approve');
req.setWorkitemId( lWorkItem.Id );
Approval.ProcessResult result =  Approval.process( req );

After invoke this method the record was approved BUT no one Approve Action was called.

Somebody knows why?

Tks for help.