cancel all awaiting aprovals

Richard P
Mega Guru

It seems if a change is canceled that approvers still have an outstanding task to approve a job which approval is now no longer required.

I thought it would be a buisness rule, but that didnt seem to work.

can someone advise the best way that if a a change is canceled, we then change the state of all approvals to no longer required anc close all tasks related.

thanks

1 ACCEPTED SOLUTION

Hi,



I created a UI Action on the request item table to find and cancel outstanding approvals which is a pretty similar thing to what you're doing.



I used an if(approval.next) cos the existing BRs take into account the other approvals and mark them as not required....   It does highlight how to update the approval record though.... looks like you're referring to client script functions setValue(X,Y) etc etc



  approval.state = 'rejected';


  approval.comments = "Cancelled by " + user;


  approval.update();




Example Script


var user = gs.getUserDisplayName();



var approval = new GlideRecord('sysapproval_approver');  


      approval.addQuery('sysapproval', current.sys_id);


      approval.addQuery('state', 'requested');  


      approval.query();  



if(approval.next()){



  approval.state = 'rejected';


  approval.comments = "Cancelled by " + user;


  approval.update();


  gs.addInfoMessage("Request Item: " + current.number + " has been cancelled");




} else {


  gs.addInfoMessage("Request Item: " + current.number + " cannot be cancelled as there are no active approvals");


}//end else


View solution in original post

10 REPLIES 10

yes, all approvals still outstanding on that change request should be set to "No Longer Required"