ProcessInstanceWorkitem[] workItems = [ SELECT Id FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId = 'recordId' AND ProcessInstance.Status = 'Pending' ];
Approval.ProcessWorkitemRequest pwr = new Approval.ProcessWorkitemRequest();
pwr.setAction('Removed');
pwr.setWorkItemId(workItems[0].id);
Approval.ProcessResult result = Approval.process(pwr);
Note: This Code will work only If you replace recordId with an Id in the org in Soql query.
Approval.ProcessWorkitemRequest pwr = new Approval.ProcessWorkitemRequest();
pwr.setAction('Removed');
pwr.setWorkItemId(workItems[0].id);
Approval.ProcessResult result = Approval.process(pwr);
Note: This Code will work only If you replace recordId with an Id in the org in Soql query.
No comments:
Post a Comment