Applying New workflow version to old records/workflow

kduong
Giga Contributor

Is it possible to apply the latest workflow version to old records/workflow?

I know there is a way to restart the workflow. Am I correct in saying that the restart workflow will restart the current workflow associated with the record? meaning it will restart the old workflow?

1 ACCEPTED SOLUTION

HI Ken,



I don't have script handy. Please refer below link on how you can restart workflow.


Workflow Script - ServiceNow Wiki


View solution in original post

11 REPLIES 11

Thanks Ken for the update.


Please do mark my original answer as correct once the issue is resolved, so others can find it quickly when searching for the same question



Kindly let me know if you have any questions.


Community Alums
Not applicable

Try using below script, it works for me: 

I'm using background script:

var gr = new GlideRecord('add_table_name');
gr.addEncodedQuery("add_your_query_here");
gr.query();
while (gr.next()) // use while for multiple, if for single record
{
var wkfw = new Workflow();
wkfw.deleteWorkflow(gr); // this will delete the workflow from the record 
gr.add_field_name = 'add_field_value'; // update the record to attach the new workflow, the update should be matching with the trigger condition of the updated workflow version. For eg. gr.state = 'In Progress;'
gr.update();
}

Please mark this answer as true, if it solves your problem.