- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 12:57 AM
Hello All,
I created a after BR to cancel flow_context of the current ritm, the ritm is cancelling but upon checking the flow context record, it is completed instead of cancelled.
Can anyone check my BR?:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 01:54 AM
@Al-jhon Please create a BR on sc_req_item table and add below code to it
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 02:06 AM
try this once
var flow = new GlideRecord("sys_flow_context");
flow.addQuery('source_record', current.getUniqueValue());
flow.addEncodedQuery('stateINWAITING,IN_PROGRESS,QUEUED');
flow.query();
if(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');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 01:04 AM
@Al-jhon use sn_fd.FlowAPI to cancel the flow context.
Please check below link, you will find code for cancelling flow context.
Please mark as correct answer if this solves your issue
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 01:26 AM - edited 05-31-2023 01:28 AM
Hello @jaheerhattiwale , i updated my script into:
But the flow context state is still completed though the RITM state has been cancelled.
So only the state on the flow context record is complete and not cancelled. Any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 01:32 AM
@Al-jhon to the cancel function you must pass the sys I'd of flow context in first parameter.
But currently you are passing ritm sys I'd as first parameter.
So please pass flow context sys I'd as first parameter to cancel function.
To get flow context sys I'd you need to query sys_flow_context table.
Please mark all the answers on this question as correct answers if this solves your issue
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 01:54 AM
@Al-jhon Please create a BR on sc_req_item table and add below code to it
ServiceNow Community Rising Star, Class of 2023