- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2022 03:57 AM
I have a Workflow set to run on RITM that has a timer activity - this appears to be 'broke' on some, not all, of the specific Catalog Item type. Is it possible to cancel the running workflow on single RITM records instead of a whole set or type?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2022 06:30 AM
to cancel the workflow you can use this script and specify the RITM sysId
you can run this in background script
var gr = new GlideRecord("sc_req_item");
gr.addQuery("number", "RITM001");
gr.query();
if (gr.next()) {
// cancel old running workflow
var flows = new Workflow().getRunningFlows(gr);
while(flows.next()) {
new Workflow().cancelContext(flows);
}
}
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
‎05-15-2022 04:12 AM
Hi Carlav,
Check out the documentaiton here
It can be done either by script, or by navigating to "Workflow > Active Contexts".
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 06:19 AM
I didn't know about the Active Contexts, that is helpful but somehow the specific RITM I was looking for didn't show up there. I used a script from another answer and was able to cancel. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2022 04:14 AM
Hi,
You can cancelled the workflow from workflow context.
1) Navigate to Workflows ---> Active Contexts.
2) On the List View, select the Workflow you want to Cancel.
3) Open that record and Click the UI Action Cancel.
OR you can try this script in background scripts.
var cancelWorkflow = new GlideRecord("sc_req_item");
cancelWorkflow.addQuery("sys_id", "RITM_sys_id");
cancelWorkflow.query();
if (cancelWorkflow.next()) {
new WorkflowApprovalUtils().cancel(cancelWorkflow); // cancel workflow
}
Thanks!
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2022 06:30 AM
to cancel the workflow you can use this script and specify the RITM sysId
you can run this in background script
var gr = new GlideRecord("sc_req_item");
gr.addQuery("number", "RITM001");
gr.query();
if (gr.next()) {
// cancel old running workflow
var flows = new Workflow().getRunningFlows(gr);
while(flows.next()) {
new Workflow().cancelContext(flows);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader