If multiple locations are selected then send approvals in parallel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello,
I created a catalog item and added a Location dropdown selection with 4 options (Bardon, Cambridge Gateshead and Leeds).
I created 4 approval requests on the flow:
If Bardon is selected then an approval is sent to Tensor-UKBAR1-Approvers
If Cambridge is selected then an approval is sent to Tensor-UKCAM1-Approvers
If Gateshead is selected then an approval is sent to Tensor-UKGAT1-Approvers
If Leeds is selected then an approval is sent to Tensor-UKLEE1-Approvers
If multiple locations are selected then I need to send approvals in parallel (for example, if Gateshead and Bardon are selected then send two separate approvals to Tensor-UKGAT1-Approvers and Tensor-UKBAR1-Approvers (I am not sure how to set up this part). Any help you can give is greatly appreciated, thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @DeIvory Gordon
This article might help you
https://www.servicenow.com/community/itsm-forum/parallel-approvals-in-flow-designer-proposed-solutio...
This helps other users find accurate and useful information more easily
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @DeIvory Gordon,
A Select Box only holds one value, so you'll need to change Location to a List Collector on cmn_location (filtered to your four sites) before anyone can pick more than one.
I'd steer away from putting several Ask for Approval actions inside a "Do the following in parallel" block on the same RITM. Each one sets up a watcher on the same record, so when one group approves, the others can think they're done too and move on early.
What works better is a single Ask for Approval action with a scripted rule. Add the action on the Requested Item, click the f(x) toggle on the Rules input and paste this in. Swap the placeholders for your real location and group sys_ids, and change "locations" if your variable has a different name.
var map = { 'BARDON_LOC_ID':'UKBAR1_GRP_ID', 'CAM_LOC_ID':'UKCAM1_GRP_ID', 'GAT_LOC_ID':'UKGAT1_GRP_ID', 'LEE_LOC_ID':'UKLEE1_GRP_ID' };
var locs = (fd_data.trigger.request_item.variables.locations + '').split(',');
var grps = [];
locs.forEach(function (l) { l = l.trim(); if (map[l]) grps.push(map[l]); });
if (!grps.length) return '';
var rule = grps.map(function (g, i) { return (i ? '&AnyG[' : 'ApprovesAnyG[') + g + ']'; }).join('');
return rule + 'OrRejectsAnyG[' + grps.join(',') + ']';
So if someone picks Gateshead and Bardon, the rule comes out as ApprovesAnyG[gateshead group]&AnyG[bardon group]OrRejectsAnyG[gateshead group,bardon group]. AnyG means one person from that group is enough, the & means every selected group has to approve, and the OrRejectsAnyG part means a rejection from any of them rejects the whole request. Both groups get their approvals at the same time, and the flow waits until they've all signed off. After the action, add an If on its Approval State output to handle approved and rejected.
If you'd prefer four checkboxes over a List Collector, the same idea works. Just check each checkbox in the script and add that site's group to grps when it's true.
When testing, try one location first, then two, and make sure both approvals sit in Requested until each group acts. If the action comes back as Skipped with no approval records, add gs.info(rule) before the return and compare it with the rule the builder creates when you set it up by hand. Usually it's a stray space in a sys_id, a group with no active members, or nothing matching the map.
Thanks
