Cancel flow designer from a server side script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 08:02 AM
Hello experts,
Is there a way to cancel a flow designer flow from a server side script running on a RITM. Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 08:11 AM
Hello @deepika46 ,
Please find the below link which has the script and will help you to cancel the flow designer.
https://www.servicenow.com/community/now-platform-forum/cancel-flow-designer-flow/m-p/1084073
Thank you,
Omkar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 10:04 AM
@deepika46 You should use the following script to cancel the flow.
var now_GR = new GlideRecord("sys_flow_context");
now_GR.addQuery("source_record", "436c8d344732211092c98021336d43aa"); //Replace with the sys_id of your RITM
now_GR.query();
while (now_GR.next()) {
sn_fd.FlowAPI.cancel(now_GR.getUniqueValue(), 'Canceling Test Flows');
}
Make sure to replace source_record sys_id value with the sys_id of your RITM.
Please mark this answer correct and helpful if it manages to answer your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 12:10 AM
It is giving the following error
Flow cannot be cancelled as the context id: fef1a4951bb5b51033ff62cce54bcb64 doesn't exist
The id does exist but still it is giving the error

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 12:33 AM
@deepika46 Could you please check if a context for your RITM exists within sys_flow_context table.