this article now superceded by a better solution, go to:
http://www.cloudminus89.com/2022/07/servicenow-kill-workflows-executing.html
var sQuery="active=true^started<javascript:gs.beginningOfLast12Months()";
var grWF=new GlideRecord('wf_context');
grWF.addQuery(sQuery);
grWF.query();
gs.print(grWF.getRowCount());
while (grWF.next()){
var grTask=new GlideRecord('task');
grTask.addInactiveQuery();
grTask.addQuery('sys_id', grWF.id);
grTask.query();
if (grTask.next()){
gs.print('ticket ' + grTask.number);
grWF.state='cancelled';
grWF.active=false;
var cancel_sysid=grWF.update();
gs.print(cancel_sysid + ': cancelled workflow context');
//break;
}
}
Comments
Post a Comment