Cancel flow designer from a server side script

deepika46
Tera Contributor

Hello experts,

 

Is there a way to cancel a flow designer flow from a server side script running on a RITM. Thanks in advance!

7 REPLIES 7

Omkar Kumbhar
Mega Sage
Mega Sage

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

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

Sandeep Rajput
Tera Patron
Tera Patron

@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.

 

Source: https://docs.servicenow.com/en-US/bundle/vancouver-api-reference/page/app-store/dev_portal/API_refer...

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

@deepika46 Could you please check if a context for your RITM exists within sys_flow_context table.