Approvals are not cancelled for cancelled flow context.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2022 12:09 AM
Hello Community,
I have a running flow with "Ask For Approvals" action and working on a business rule which cancels the flow context once the record state changes. Flow context gets cancelled as expected but approvals still remain in "Requested" state. For the workflows we can use WorkflowApprovalUtils().cancelAll but do we have something similar that we could use for flow approvals cancellation? Code from my BR:
var flow = new GlideRecord("sys_flow_context");
flow.addQuery('source_record', current.getUniqueValue());
flow.addEncodedQuery('stateINWAITING,IN_PROGRESS,QUEUED');
flow.query();
while (flow.next()) {
sn_fd.FlowAPI.cancel(flow.getUniqueValue(), 'Cancelled by the user.');
}
- Labels:
-
compliance
-
flow designer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2022 05:27 AM
Hi,
Why are you not stopping the Flow from within Flow designer?
You could set a reject rule on the approval, and end the flow if you get a rejection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2022 03:55 AM
I have rules for reject and approve actions and flow is waiting until such conditions will be met and progressess forward if needed, however if i need to cancel the flow, for example record needs to be updated and it will have new approvers I need to cancel flow together with previous not relevant approvals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2022 05:32 AM
Hello Evaldas,
Please check once with the below script if you are able to cancel the approval as well:
var flow = new GlideRecord("sys_flow_context");
flow.addQuery('source_record', current.getUniqueValue());
flow.addEncodedQuery('stateINWAITING,IN_PROGRESS,QUEUED');
flow.query();
while (flow.next()) {
var gpa = new sn_ph.GlideProcessAutomation(flow.getUniqueValue());
gpa.cancel("manually by "+ gs.getSession().getUserName());
}
Please mark my respsone as helpful/correct, if it answer your question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2022 04:02 AM
Hello Mahendra,
I have tried this method too but it works the same way, it cancels the flow but approvals still remain in "Requested" state.