- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2019 05:32 AM
Hi . I have updated my workflow and want to move to Prod . I did some research and found that the active records will still be using the old context as the workflow already started for them and they are in the middle . But there are records that were created but are still in the first step of the workflow. I would like to update these records with the new context of workflow. Can anyone please help me with the code on how to achieve this .
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2019 05:42 AM
While I don't have time to write entire script, it's going to a pretty standard GlideRecord lookup for the records you want to restart. The key is going to be the Workflow() class. Use the cancel() method to kill the workflows on the records and then right after that, use startFlow() method to start a specific flow.
Developer: startFlow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2019 05:42 AM
While I don't have time to write entire script, it's going to a pretty standard GlideRecord lookup for the records you want to restart. The key is going to be the Workflow() class. Use the cancel() method to kill the workflows on the records and then right after that, use startFlow() method to start a specific flow.
Developer: startFlow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2019 05:34 AM
Thanks Chuck
I have wrote the following to resolve my issue
var gr = new GlideRecord ('table name');
gr.addEncodedQuery('active=true^state=41');
gr.query();
while (gr.next()) {
var oldWorkflow = new Workflow();
oldWorkflow.cancel(gr);
var w = new Workflow();
var context = w.startFlow('fe694ca94ffb4600e9153d728110c79c', gr, gr.update());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2019 09:55 AM
I think this will do it using the appropriate gr for the task
new Workflow().restartWorkflow(gr, false);//restartWorkflow related workflows

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2019 06:13 PM
According to how I read it, restartWorkflow() simply triggers the same workflow (restarting the context) and allowing you to reset tasks/approvals on that same flow. That's different than canceling the existing flow and starting a new specific one.