diff --git a/Specialized Areas/SubFlow/Assign Group Level Approver After Removing Already Approved/README.md b/Specialized Areas/SubFlow/Assign Group Level Approver After Removing Already Approved/README.md new file mode 100644 index 0000000000..4b0bc58ebf --- /dev/null +++ b/Specialized Areas/SubFlow/Assign Group Level Approver After Removing Already Approved/README.md @@ -0,0 +1,14 @@ +Use Case: + +When a catalog item requires a two-level approval process — Primary Level (Single Approver) and Secondary Level (Group/Department Approvers) — the system should exclude the Primary Approver from the Secondary Approval Group, if the same user is a member of both levels. + + + +Example: + +A catalog item first requires Manager ABC’s approval as the Primary Approver. + +Next, it moves to the Department/Group Approval stage. + +If Manager ABC is also part of the Group/Department Approvers, they should be excluded from the second-level approval to prevent duplicate approvals. + diff --git a/Specialized Areas/SubFlow/Assign Group Level Approver After Removing Already Approved/script.js b/Specialized Areas/SubFlow/Assign Group Level Approver After Removing Already Approved/script.js new file mode 100644 index 0000000000..35e47fb126 --- /dev/null +++ b/Specialized Areas/SubFlow/Assign Group Level Approver After Removing Already Approved/script.js @@ -0,0 +1,18 @@ + +// Get the Group Sys Id from the Input of Subflow +var group_sys_id = fd_data.subflow_inputs.group_sys_id; + + +var users = []; +var grGroupMember = new GlideRecord('sys_user_grmember'); +grGroupMember.addQuery('group.sys_id', group_sys_id); +grGroupMember.query(); +while (grGroupMember.next()) { + // Get the Primary level manager from the Subflow Input + if (grGroupMember.user.sys_id != fd_data.subflow_inputs.requested_for.manager){ + users.push(grGroupMember.user.sys_id.toString()); + } +} + +return 'ApprovesRejectsAny[' + users + ']'; +