Recall Approval Process using Apex in Salesforce

Sample Code:

ProcessInstanceWorkitem[] workItems = [ SELECT Id
                FROM ProcessInstanceWorkitem 
                WHERE ProcessInstance.TargetObjectId = '0016A00000OXbfi'
                AND ProcessInstance.Status = 'Pending' ]; 
Approval.ProcessWorkitemRequest pwr = new Approval.ProcessWorkitemRequest();  
pwr.setAction('Removed');
pwr.setWorkItemId(workItems[0].id);

Approval.ProcessResult result = Approval.process(pwr);

Output:


No comments:

Post a Comment