Restarting a specific workflow for a record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 11:21 PM
I have heard that restartWorkflow () can restart the workflow for a record. However, a client implementation has about 4 workflows running at the same time. I need to restart one of the 4 workflows and do not want to restart the other three. Is there a method available that can do this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2020 12:28 AM
Yes, you can.
Try below in background script once.
var gr = new GlideRecord('sc_req_item'); //replace table name
gr.get('sys_id_of_record'); // replace sys_id of record
var workflow = new Workflow();
workflow.cancel(gr);
var newWorkflow = new Workflow();
newWorkflow.startFlow(new Workflow().getWorkflowFromName('Pass workflow name here'), gr, '');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 01:03 PM
We needed this for a Requested Item in our instance. User in a Service Catalog Task marked the SCTASK record as Closed, instead of Cancelled. Cancelled the entire workflow! DOH!!
With the above script, I was able to salvage the RITM and it was able to get completed AND closed successfully. Thanks @Jaspal Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2020 01:07 AM
Hi,
Can you explain the need to restart the workflow?
The reason being it would start from the beginning and if any approvals etc are present it would trigger that as well
If you still want to restart please try script mentioned by Jaspal
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 08:15 AM
We have a table that has 25 different workflows running on it. Each workflow corresponds to a stage of a record belonging to that table. Multiple workflows for different other functions are also running at the same time.
The issue is we discovered that we need to revisit some of the workflow due to checks in later stages that require a revisit of one or more earlier stages.
The problem is that the workflow has already been completed for these earlier stages so we want to restart just the stages that were flagged by our code.
Most of the code that is being suggested is more of a "blunt force" method that handles all workflows and we need to deal with only that is affected.
Thanks