Restarting Cancelled Workflows (restartWorkflow())
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 10:03 AM
Can you restart a cancelled workflow? I have a number of cancelled workflows that need to be restarted but not all of them. All approvals can remain intact for each one I need to restart. I understand that the function is restartWorkflow(current,boolean) but I am not sure where to run it or how to focus on a specific cancelled workflow. Any example of how to do this would be very helpful. Thank you!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 10:53 AM
I did, yes and that is where some of the confusion for me sets in.
If I want to restart a specific workflow that was cancelled, do I run this in the Scripts - background or do I run it elsewhere?
So to do something like restartWorkflow(<sys_id_of_workflow>, true);?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 11:11 AM
You can run that in scripts - Background.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 12:31 PM
One last question:
For the first part of restartWorkflow, what sys_id or data should I put where 'current' should be? Would it be the sys_id of Workflow Context or choosing a specific activity? I've tried submitting the specific Workflow Context and the Begin Workflow activity to reset to - but nothing seems to happen.
Thanks for your info so far!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 09:06 PM
If you are running the script using Business rule then current should refer to the business rule table,Otherwise it should be gliderecord object related to the workflow you want to restart.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018 02:11 PM
So an update - I figured out how to run a script that restarts the workflow but...now it gets stuck.
In the Scripts - Background - I have the following code:
When it runs - it states that the workflow gets restarted and I can confirm when I review that RITM, it shows all pieces as restarted but it hangs at Begin.
I read that is because the source record needs to be updated in order to pass that hurdle. When I update the RITM and check the workflow - everything still sticks as "Restarted" and nothing happens.
I tried adding the Boolean 'true' (and 'false') to keep all approves in place but that doesn't work either.
Please see the ss attachment. Thoughts?
try
{
var gr = new GlideRecord("sc_req_item");
gr.addQuery("number", "RITMXXXXXX)
gr.setLimit(1);
gr.query();
if(gr.next())
{
new Workflow().restartWorkflow(gr);
}
}catch(e)
{
gs.print(e);
}