For Each Logic In Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hello everyone,
I have a field of type List on my Project form that allows selecting multiple managers (users).
What I’d like to achieve is:
When the project is submitted (or reaches a certain state),
An approval request is sent to each manager that was selected in this list field.
I’m not sure what is the best way to configure this. for each logic doesn't seem to work
Has anyone implemented something similar, or can share best practices for this scenario?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @ammar_k ,
I have created the same scenario and tested it in my PDI (list type field and selected multiple managers) and i'm able to send the approval to all the managers.
For that you need to configure your flow designer like this-
please review the screenshot and apply the code
here is the code-
----------------------------------------------------------------------------------
Please test and let me know.
If my response is helpful please accept as solution and marked as helpful for future readers.
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @ammar_k
1. Use “Ask for Approval” in a Subflow
Create a Subflow that handles approvals for each selected manager. This makes your logic reusable and modular.
2. Convert List Field to Array
If you're using a List Collector or a field that stores multiple users, convert it to an array using a “List Collector Convert to Array” action. This allows looping through each selected user.
3. Use “For Each” Logic
Inside the Flow Designer:
- Add a “For Each” action to iterate over the array of selected managers.
- Within the loop, use “Ask for Approval” for each user.
Advanced Scripted Approval Logic (Optional)
If you want to replicate group approval logic or handle primary/backup approvers, you can use Scripted Approvals:
var grps = fd_data.flow_var.approval_groups.split(',');
var rl = '';
for (var i = 0; i < grps.length; i++) {
rl += (i === 0 ? '' : '&') + 'ApprovesAnyG[' + grps[i] + ']';
}
rl += 'OrRejectsAnyG[' + fd_data.flow_var.approval_groups + ']';
return rl;
This script builds a rule that:
- Requires one approval per group
- Rejects if any group member rejects.
If the above information is helpful to you, please mark it as helpful and accept the solution.
Regards,
Raviteja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
you can use Flow which triggers when state reaches
1) Then use Flow Variable of type String
2) then use "Set Flow Variables" flow logic to grab managers of all those users
3) then use Ask for Approval and set this flow variable
OR
You can use scripted approval, check this link
Scripted Approvals in Flow Designer with Flow Variables
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hello @ammar_k, if you have all the managers already available in a field then you can simply use that field in the 'ask for approval' rule, something like below:
Regards,
Nishant