Trying to remove the manager as an approver if they are also a member of the group

lonesoac01
Giga Guru

Hello all,

 

    I am looking into the idea of removing or filtering out the assignment group manager if they are also listed as a member of the group.  Based on my observations of how the process works is that the approvers are populated based on Change Approval Definitions.  These definitions are defined as a user or group based on the Approval Definition parameters, that as far as I can tell, are not really editable in a dynamic way.  Am I correct in the conclusion that the manager cannot be filtered out of the approvers if they are also a member of the group defined in the Change Approval Definition?

 

The reason this is an issue is because many of the assignment group managers are also members of the assignment groups. We are trying to avoid any confusion if a user approved the Change request as a manager or member of the assignment group.

7 REPLIES 7

priyatam_pvp
Tera Guru

Creating a Business Rule on the sysapproval_approver table can prevent the manager from being added as an approver if they already exist as a member.

Conditions: Before Insert

source_table == 'change_request'

Code:

var grChange = new GlideRecord('change_request');

    if (grChange.get(current.document_id)) {

        var assignmentGroup = grChange.assignment_group; // Get Assignment Group

        

        if (assignmentGroup) {

            var groupManager = assignmentGroup.manager; // Get Group Manager

            

            // Check if the approver is the manager

            if (groupManager == current.approver) {

                // Verify if the manager is also a group member

                var grGroupMember = new GlideRecord('sys_user_grmember');

                grGroupMember.addQuery('group', assignmentGroup);

                grGroupMember.addQuery('user', groupManager);

                grGroupMember.query();

                

                if (grGroupMember.hasNext()) {

                    gs.info("Manager is also a member, removing from approvers.");

                    current.setAbortAction(true); // Prevent insertion

                }

            }

        }

    }


Mark it helpful if this helps you to understand. Accept the solution if this gives you the answer you're looking for
Kind Regards,
Priyatam Patchipulusu

First, thank you for the reply!  This is definitely a 'front runner' solution for me if I cannot figure out how to adjust the action in Flow Designer.

Martin Friedel
Mega Sage

Hello,

 

I have had kind of similar requirement in one of my previous implementations. If you are using Flow Designer, try use scripted approval. Here is an article which helped me a lot: 

 

Scripted Approvals in Flow Designer with Flow Variables 

 

If my answer helped you, please accept it as correct and mark helpful, thank you 👍
Martin

lonesoac01
Giga Guru

I found the documentation for the Flow action at: https://www.servicenow.com/docs/bundle/washingtondc-it-service-management/page/product/change-manage... What I found interesting is that SOMEHOW I have extra fields in my Action compared to the ServiceNow documentation.  How is that possible?Screenshot 2025-02-25 082135.png