- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2024 08:59 PM
Hi does anyone know if there is a way to end a flow and any subflows that is running against a record if the user cancels the record. I have a few wait conditions etc. that will never run if the user cancels the record.
Many thanks
Max
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 02:22 AM
Hi @CCZMAX1,
Have a look at the OOB Business Rule - cancel flow on request cancelled/deleted (sys_script.do?sys_id=062422410f2100108af26b198b767eb0)
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 02:34 AM
Hi @CCZMAX1
please check this:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0750702
-----------------------------------------------------------------------------------
Please consider marking my reply as Helpful 👍 and/or Accept Solution ✔️✔️ , if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 02:22 AM
Hi @CCZMAX1,
Have a look at the OOB Business Rule - cancel flow on request cancelled/deleted (sys_script.do?sys_id=062422410f2100108af26b198b767eb0)
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 02:34 AM
Hi @CCZMAX1
please check this:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0750702
-----------------------------------------------------------------------------------
Please consider marking my reply as Helpful 👍 and/or Accept Solution ✔️✔️ , if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 06:11 AM
Hi @CCZMAX1 ,
Please try BR
Add a script action to the Business Rule to check for cancellation and terminate any active flows.
(function executeRule(current, previous /*null when async*/) {
// Check if the state has changed to 'Canceled'
if (current.state == 'Canceled' && current.state != previous.state) {
// Query active flows associated with the current record
var activeFlows = new GlideRecord('sys_flow_instance');
activeFlows.addQuery('table', current.getTableName()); // Adjust to your table name
activeFlows.addQuery('record_id', current.sys_id); // Adjust to your record's sys_id
activeFlows.addQuery('state', 'IN', 'started,running,pending');
activeFlows.query();
while (activeFlows.next()) {
// Terminate each active flow
var flowInstance = new FlowInstance();
flowInstance.terminate(activeFlows.sys_id);
}
}
})(current, previous);