Ask for approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Hi,
I have one requirement,
How can we configure an approval process in Flow Designer where approvals are dynamically routed to specific group members based on conditional field checks?
If a request meets specific business and IT function criteria (such as matching Engineering, CTO, CDO, or CPO with a non-IT classification), how do we target the correct group's sys_id to trigger the approval workflow?
How do we implement an "anyone approves or rejects" rule structure using group syntax so that if any member of the matched group takes action, it satisfies the approval step?
sample Script I used :var business = fd_data._1__get_catalog_variables.business_function;
var it = fd_data._1__get_catalog_variables.it_function.u_short_name || '';var approverSysId = '';
if ((business == 'a' || business == 'b' || business == 'c' ) {
approverSysId = 'dd897ef5c3b01690wrd3452dsc0131a7';
}
else if (business && business.indexOf('d) === 0 && it == 'IT') {
approverSysId = '8039beb5c3b016900193efcd2b0131f7';
}
else {
approverSysId = 'e4f93af5c3b016900193efcd2b0131a2';
}return 'ApprovesAnyU[' + approverSysId + ']OrRejectsAnyU[' + approverSysId + ']';
It is not working. what error I am doing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Thank you for marking my response as helpful.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hello @Kanimitha S ,
The issue might be that ApprovesAnyU[...] expects a comma-separated list of individual user sys_ids, not a group sys_id, so even with valid IDs, passing a group's sys_id there won't expand to its members.
Also I noticed some syntax errors...
Try with this script :
var business = fd_data._1__get_catalog_variables.business_function;
var it = fd_data._1__get_catalog_variables.it_function.u_short_name || '';
var groupSysId = '';
if (business == 'a' || business == 'b' || business == 'c') {
groupSysId = 'dd897ef5c3b01690193efcd2b0131a7';
} else if (business && business.indexOf('d') === 0 && it == 'IT') {
groupSysId = '8039beb5c3b016900193efcd2b0131f7';
} else {
groupSysId = 'e4f93af5c3b016900193efcd2b0131a2';
}
// Expand the group into its member user sys_ids
var userIds = [];
var grm = new GlideRecord('sys_user_grmember');
grm.addQuery('group', groupSysId);
grm.addActiveQuery(); // only active members
grm.query();
while (grm.next()) {
userIds.push(grm.getValue('user'));
}
if (userIds.length === 0) {
gs.error('No active members found for group ' + groupSysId);
}
var idList = userIds.join(',');
return 'ApprovesAnyU[' + idList + ']OrRejectsAnyU[' + idList + ']';
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
working fine Thank you all for your support