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
Becky Miller 15Becky Miller 15 

Approval Process - Recall already Approved records?

I am trying to be a Recall Button on the Quote Page:  I am receiving the error: A problem with the OnClick JavaScript for this button or link was encountered:  Unexpected Identifier.

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();
        req.setAction('Removed');        
        req.setWorkitemId(piwi.get(0).Id);
   
        Approval.process(req,false);
    }
}




{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} 


var r = confirm("Are you sure want to recall the approval process?"); 
if(r == true) 

sforce.apex.execute("approvalRecall","recallApproval",{ID:"{!Quote.Id}"}); 
alert("Approval has been recalled"); 
window.open('/{!Quote.Id}'); 

else 

alert("Recall Cancelled"); 
}{!Quote.Id}
Swaraj Behera 7Swaraj Behera 7
Hi Becky,
Can you use id lower case instead capital letter.
Let us know if it works.

Thanks
Becky Miller 15Becky Miller 15
That did not solve anything.  Nice idea though.
Anil MalneniAnil Malneni
can you replace ID to recId....

sforce.apex.execute("approvalRecall","recallApproval",{recId:"{!Quote.Id}"}); 

let me know if this works..

Thank you,
Anil