kill old workflows
Import
·
May 17, 2019
·
article
this article now superceded by a better solution, go to:
http://www.cloudminus89.com/2022/07/servicenow-kill-workflows-executing.html
var sQuery="active=truestarted<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; }
}
View original source
http://www.cloudminus89.com/2019/05/kill-old-workflows.html