Tuesday, August 22, 2017

What happens to the currently running workflow if new changes are made to the workflow



Once a record triggers a workflow, it keeps the original context version through the life of the flow. Only new workflow contexts created after you publish the change will use the new flow.


When a new version of an existing workflow is published, the changes are not applied to running workflow contexts. Any currently running workflow context continues using the workflow version that was available when the workflow started. The next time the workflow runs, it uses the updated, published version.

Auto close standard change/incidents after 5 days

The following script can be schedule to auto close the standard changes/incidents after 5 days to auto close



var changeGR = new GlideRecord('change_request');
changeGR.addQuery('type', 'Standard');
changeGR.addQuery('state', 0);
changeGR.query();
while(changeGR.next()) {
var dif = gs.calDateDiff(changeGR.sys_updated_on, gs.nowDateTime(), true);
gs.print(changeGR.number);
if(dif >= 5*86400){
         changeGR.state = 3;
         changeGR.comments = 'Change Request automatically closed after 5 days in the Review state.';
         changeGR.active = false;
         changeGR.update();
      }
}