fix script to kill old ageing workflows

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

Popular posts from this blog

Running transform maps asynchronously

Post a command to the ECC queue for the mid server to initiate a powershell file copy

GlideRecord setValue