Parallel Approvals with Flow when group names & number of groups is dynamic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 03:31 AM - edited 05-28-2025 03:33 AM
Hi Community,
I wanted to share an interesting use case I recently worked on involving parallel approvals in ServiceNow, where the number of approval groups is dynamic and determined at runtime.
Business Context
In many processes—like Change Management or Knowledge publication—it's common to require approvals from multiple stakeholder groups before moving forward. ServiceNow’s “Ask for Approvals” action in Flow Designer helps initiate and manage these approvals.However, by default, approvals are handled sequentially.
The Challenge
Flow Designer does have a “Do the following in parallel” option, which can trigger parallel branches—but this only works if you know the exact number of groups at design time.
But what if:The number of approval groups is dynamic?The groups are not known in advance, and come from related tasks or other runtime logic?
That’s where it gets tricky.
Real Use Case
In our scenario:
When a Change Request enters the Assess state, the Coordinator creates multiple Change Tasks.Each task is assigned to a specific assignment group, based on the work required.
When the “Request Approval” button is clicked:The Change moves to the Authorize state and the approval requests need to go out to each unique group involved across all Change Tasks.
!Important constraint: If a group appears in multiple tasks, it should only receive one approval request.
Key Requirements
Number of tasks (and groups) is not fixed.
Assignment groups are assigned dynamically.
No duplicate approvals per group.
The Solution
Since Flow Designer doesn’t provide a built-in way to dynamically handle this kind of parallel approval logic, I built a custom Flow action that:
Pulls all assignment groups from the Change Tasks related to the Change Request.
Filters out duplicate groups.
Triggers approvals in parallel for each unique group using a custom logic (like looping with subflows or script actions)
Image 1: Figurative representation of the custom action
Image 2:Mother flow which calls the action in Flow Step 1
Image 3: Inputs of the Flow action
Image 4: Step 1 which Looks up the Change Task Records
Image 5:script step which creates teh approval & reject rule.
(function execute(inputs, outputs) { var groupsArray = []; var i = 1; groupsArray[0]=inputs.changeAssignmentGroup; var appr= "ApprovesAnyG["+ groupsArray[0] +"]" ; while(inputs.changeTask.next()) { if(groupsArray.indexOf(inputs.changeTask.getValue("assignment_group")) != -1) { //do nothing } else { groupsArray[i]=inputs.changeTask.getValue("assignment_group"); if(i!=0) { appr=appr+"&" } appr= appr + "ApprovesAnyG["+ groupsArray[i] +"]" ; i += 1; } } outputs.approvalrule=appr+"OrRejectsAnyG["+groupsArray.toString()+"]"; outputs.answercount=inputs.parameterCount; outputs.assignmentgrouparray=groupsArray.toString(); })(inputs, outputs);
Image 6: Outputs of the custom action being assigned
Image 7: Mother Flow using the output of the custom action -approve/reject rule
This approach ensured that each relevant group received an approval request at the same time, regardless of how many groups were involved—and without sending duplicate requests.
Has anyone else tackled a similar challenge? Would love to hear how others approached dynamic parallel approvals in Flow Designer.
Thanks!
Amruta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 03:37 AM
Yes. But we used a simple flow variable to get the unique groups, did a lookup to the groups table and ran the approval action for each group.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark