FLow designer Approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
//we want to send approval to group manager and manager's manager . how to achieve this using flow designer ask for approva;
(function() { var approvers = ''; var grp = new GlideRecord('sys_user_group'); if (grp.get('90dd4dc3db731200fed3b33fdf961917')) { var mgr = grp.getValue('manager'); if (mgr) { approvers = mgr; var usr = new GlideRecord('sys_user'); if (usr.get(mgr)) { var mgr2 = usr.getValue('manager'); if (mgr2) approvers += ',' + mgr2; } } } return 'ApprovesAll[' + approvers + ']RejectsAny[' + approvers + ']'; })();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Rajeevreddy ,
To help us fix this, could you clarify exactly how it is not working?
Does the Flow execution show an Error state (Red)?
Or does it finish successfully, but the Approvers list is empty?
In the Flow Execution Details, did you check if that specific Group SysID actually exists in the instance you are testing?
Let us know these details so we can provide the correct fix.
Best regards, Brandão.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
It is skipping and approvers are empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Rajeevreddy ,
In Flow Designer, use the Ask for Approval action with Approvers set to Script. Fetch the group manager and the manager’s manager from sys_user_group and sys_user tables, return them as an array, and Flow Designer will handle the approval automatically.
Use this script in the Approvers (Script) field:
(function () {
var approvers = [];
var grp = new GlideRecord('sys_user_group');
// Replace with dynamic group sys_id if possible
if (grp.get('90dd4dc3db731200fed3b33fdf961917')) {
// Group Manager
if (grp.manager) {
approvers.push(grp.manager.toString());
// Manager's Manager
var usr = new GlideRecord('sys_user');
if (usr.get(grp.manager) && usr.manager) {
approvers.push(usr.manager.toString());
}
}
}
return approvers;
})();
