Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Cancel the Flow Designer on the Background Script

Vamsi43
Tera Contributor

Hello Everyone,

I want to Cancel the Flow Designer for the current record via Background Script. how to do it?

 

var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', 'xxxxx');
gr.query();

if(gr.next()){
gr.state=Closed;
gr.update();

}

 

 

Thanks

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@Vamsi43 Please refer to this support article https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0959612 

 

Here is a sample from it.

 

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 the response helpful and accepted solution if it manages to answer your question.

View solution in original post

1 REPLY 1

Sandeep Rajput
Tera Patron
Tera Patron

@Vamsi43 Please refer to this support article https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0959612 

 

Here is a sample from it.

 

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 the response helpful and accepted solution if it manages to answer your question.