How to cancel a flow engine context in state "error"

Evelyne D_
Tera Contributor

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

 
 
 
1 ACCEPTED SOLUTION

@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');
}

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

View solution in original post

4 REPLIES 4

shyamkumar VK
Kilo Patron

@Evelyne D_ ,

Please refer to this support article

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0959612

 

Regards,

Shyamkumar

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Sumanth16
Kilo Patron

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

 

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

 

@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');
}

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar