You need to sign in to do that
Don't have an account?

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}
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}
Can you use id lower case instead capital letter.
Let us know if it works.
Thanks
sforce.apex.execute("approvalRecall","recallApproval",{recId:"{!Quote.Id}"});
let me know if this works..
Thank you,
Anil