- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 07:45 AM
Hi all,
The execution of a flow in flow designer ran into an error and I would like to cancel the execution of the flow. I have a button to restart or delete the flow, but not to cancel it.
Could you please advice on a way to cancel the execution?
Thanks in advance for your help
Solved! Go to Solution.
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 08:31 AM
@Evelyne D_ , in this Case please run this Following script in scripts background ,
Pass your flow name into the script and execute it will cancel the flow and stops executing
var now_GR = new GlideRecord("sys_flow_context");
now_GR.addQuery("name", "NAME OF FLOW TO CANCEL HERE");
now_GR.query();
while (now_GR.next()) {
sn_fd.FlowAPI.cancel(now_GR.getUniqueValue(), 'Canceling Test Flows');
}
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 08:06 AM
Please refer to this support article
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0959612
Regards,
Shyamkumar
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 08:11 AM
Hi @Evelyne D_ ,
We have an OOTB "Cancel" UI action on the "sys_flow_context" table to cancel the flow.
But instead doing it manually every time on a record, we can write a Business rule and define it on the table where the flow has to be cancelled and include the conditions on when to run.
The Script inside the business rule will be:
var referer = GlideTransaction.get().getRequest().getHeader("referer");
action.setredirectURL(referer);
var gpa = new sn_ph.GlideProcessAutomation(current.sys_id);
gpa.cancel("manually by "+ gs.getSession().getUserName());
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 08:26 AM
Hi Sumanth,
My flow is in state "Error", not "Waiting" or "In progress". In other states, I can see the UI action, but my question is about flows in state "error". Can you advise on this?
Thanks
Evelyne
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 08:31 AM
@Evelyne D_ , in this Case please run this Following script in scripts background ,
Pass your flow name into the script and execute it will cancel the flow and stops executing
var now_GR = new GlideRecord("sys_flow_context");
now_GR.addQuery("name", "NAME OF FLOW TO CANCEL HERE");
now_GR.query();
while (now_GR.next()) {
sn_fd.FlowAPI.cancel(now_GR.getUniqueValue(), 'Canceling Test Flows');
}
Regards,
Shyamkumar