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
Rabbani sayyed 8Rabbani sayyed 8 

How to recall a approved record using custom button (onclick javascript) ? can anyone share me the code for this?

salesforce mesalesforce me
hi check this once...
Apex Class:

global class approvalRecall
    webservice static void recallApproval(Id recId)    
        List<ProcessInstanceWorkitem> piwi = [SELECT Id, ProcessInstanceId, ProcessInstance.TargetObjectId FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: recId];
        Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();

Custom Button Javascript:

var r = confirm("Are you sure want to recall the approval process?"); 
if(r == true) 
alert("Approval has been recalled");'/{!Member__c.Id}'); 
alert("Recall Cancelled");