Restart Workflow for one REQ or RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2017 07:42 AM
Hi Guys,
Is there a simple Business Rule for restarting a workflow on one particular REQ or RITM?
In the event we find an issue, something is incorrect, etc...can you just restart a workflow on one particular Request is what I am looking for.
I've seen this code, but not sure how to use it for one particular item:
new WorkflowApprovalUtils().cancelAll(current, comment);
new Workflow().restartWorkflow(current);
If anyone has a script example that would be great!
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2017 08:03 AM
You can create UI action 'Restart Workflow' on Request. This button only visible to admins for us and if something goes wrong, we correct few values and restart the workflow.
We have the following code in the UI action.
new WorkflowApprovalUtils().reset(current, "Restarting the workflow");
current.state = "requested";
current.u_last_approved_by = "None";
current.request_state = "requested";
current.update();
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2017 08:48 AM
So I tried this, but the workflow doesn't seem to restart. Just hangs at the Begin step:
This was when I first made the request:
This is when I clicked "Restart Workflow" button:
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2017 08:55 AM
Try below code
//mark all existing approvals for the change as 'cancelled' and restart the workflow to create new approvals
//where current is a task record with a workflow context
new WorkflowApprovalUtils().cancelAll(current, comment);
new Workflow().restartWorkflow(current);
Reference:
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2017 08:15 AM
I had the same issue (restarted workflow stuck at Begin). It would seem that "restartWorkflow" is something of a misnomer. What it actually does is reset the workflow without starting it running. Once it is reset, you have to "runFlows". This worked for me:
wkflw = new Workflow();
wkflw.restartWorkflow(current);
wkflw.runFlows(current, 'update');