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-09-2022 09:49 AM
Hello Evaldas,
If that is the case then can we first cancel the approvals and then cancel the flow:
var sysApproval = new GlideRecord("sysapproval_approver");
sysApproval.addEncodedQuery("state=requested^sysapproval=" + current.getUniqueValue());
sysApproval.query();
while (sysApproval.next()) {
sysApproval.setValue("state", "cancelled");
sysApproval.update();
}
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
‎08-17-2023 11:08 PM
Do you have a new solution to this problem? I have also encountered the same problem,and I am looking forward to your reply