Issue
Learn how to cancel an running flow context on any table when specific conditions are met.
Release
All Flow Designer supported versions
Resolution
The default Cancel UI action on the flow context table (sys_flow_context) cancels flows manually. To automate this process, create a business rule on the table where you want to cancel flows:
- Go to System Definition > Business Rules.
- Select New.
- Define the conditions that trigger flow cancellation.
- Add this script to the business rule:
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());