- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2021 04:26 AM
Hello Community,
I want to cancel running Flow contexts with a certain query. These flow contexts are related to many different RITMs so it's not just contexts for 1 RITM, but for like 1000 RITM.
Encoded query would be "state=WAITING^sys_created_bySTARTSWITHabde^name=FlowName"
Could someone assist with this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2021 05:39 AM
Hi,
sample script below
(function() {
var now_GR = new GlideRecord('incident');
now_GR.addQuery('number', 'INC0000050');
now_GR.query();
if(now_GR.next()){
// get the flow context for this INC
var flow = new GlideRecord("sys_flow_context");
flow.addQuery('name', 'myFlow'); // flow name
flow.addQuery('source_record', now_GR.getUniqueValue());
flow.addEncodedQuery('stateINWAITING,IN_PROGRESS,QUEUED');
flow.query();
while(flow.next()){
var gpa = new sn_ph.GlideProcessAutomation(flow.getValue('sys_id'));
if (!gpa.isTerminated()) {
//cancel the flow and provide the reason
gpa.cancel('Cancelling this flow');
}
}
}
})();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2021 09:55 PM
Hope you are doing good.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
If not, please let us know if you need some more assistance.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader