- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 05:15 AM
I have an Requirement to restart an existing 'Workflow'.A task already got triggered in the existing one, i want to restart it from the beginning.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 05:18 AM
Hi Midhun,
Take a look at the Workflow script include. There is a method called restartWorkflow(). It takes two arguments, the gliderecord object related to the workflow you want to restart, and a boolean to indicate whether to keep approvals in their current state or reset those as well.
Reference:
Workflow Script - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 08:47 AM
This example doesn't show the maintainStateFlag in the restartWorkflow function. It looks like it defaults to true but the user might want a false to reset all of the values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 05:23 AM
Hi Midhun to restart workflow i created a bussinees rule on update.
That may help you
function onAfter(current, previous) {
//This function will be automatically called when this rule is processed.
}
forceReqItemUpdate();
function forceReqItemUpdate() {
var wf = new Workflow();
var ri = new GlideRecord('u_trips');
ri.addQuery('sys_id', current.sys_id);
ri.query();
if (ri.next()) {
wf.restartWorkflow(current);
}
}
Thanks
Akash Sharma
PS hit Like Correct if helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 06:01 AM
Hi All,
Am testing in background script:
Am using
new WorkflowApprovalUtils().cancelAll(current, comment);
new Workflow().restartWorkflow(current);
Still workflow is in same stage.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 06:02 AM
Did you make a record called "current"?
This video shows how you can be very effective using scripts background.
Faster Server Side Script Development and Test