this article now superceded by a better solution, go to:
http://www.cloudminus89.com/2022/07/servicenow-kill-workflows-executing.html
these workflows may be stuck in limbo on tickets since closed
var sQuery="active=true^started<javascript:gs.dateGenerate('2018-01-02','00:00:00')";
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);
//break;
}
}
Comments
Post a Comment