How to restart workflow for a requested item (RITM) using a background script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 05:28 AM
Hi All,
I need to cancel current workflow and start a new workflow as current workflows have stucked in a wrong script activity in requested items (RITMs). How can i achieve it?
Thanks,
Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 05:35 AM
Hi,
var gr = new GlideRecord("sc_req_item");
if(gr.get('sys_id')){
new Workflow().restartWorkflow(gr);
}
Thank you
Dante
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 05:36 AM
Hi @Dante,
Thanks for the quick reply 🙂 Will it also cancel existing workflows attached to a RITM??
Thanks,
KUMAR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 05:44 AM
For cancelling you should add this also:
new WorkflowApprovalUtils().cancelAll(gr, comment);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 05:37 AM
See this thread with Chuck Tomasi's correct answer: https://community.servicenow.com/community?id=community_question&sys_id=3e998ba5db5cdbc01dcaf3231f9619ad
"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."