Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Exclude specific person from a group approval

t_a_rogers
Kilo Expert

Hi All,


In our Change Management process we have 3 linear approvals:

1) Peer approval (Should be a team member double checking the work in the change request)

2) Manager approval (a team manager validating this should take place) - Sends to Assignment Group "Manager"

3) CAB approval

Right now step 1 sends a group approval request to all members of the Assignment Group. The issue with this is some groups have the Manager also as a team member, so the manager sees the peer approval request and tries to approve that. We tell them   "Don't approve the peer approval if you're a manager" but they are confused.


SO: Is there a way to exclude a person from a group approval? Say, ServiceNow checks and sees you are a group manager and it skips sending you the approval request on the peer approval step?


I have no idea how to write this type of script, so your input would be helpful


Thanks,
Travis

1 ACCEPTED SOLUTION

Here you go



answer = [];


var gr= new GlideRecord('sys_user_grmember');


gr.addQuery('group',current.assignment_group);


gr.addQuery('user','!=',current.assignment_group.manager);


gr.query();


while(gr.next()){


answer.push(gr.getValue('user'));


}


View solution in original post

17 REPLIES 17

could you give me a hand please workflow level approvals


santoshkomerave
Tera Contributor

I Have tried this, but it did not worked for me.

 

Here is my script:

 

var answer = [];
var req_for = current.request.opened_by; // Requested For value
workflow.info("Requested For:"+req_for); //Getting correct sys_id value for santosh 89d2cbd1db5813402bdc5068dc961933 with toString()

var gr= new GlideRecord('sys_user_grmember');

gr.addQuery('group',current.variables.u_assignment_group.sys_id);
workflow.info("Checking Assignment group Value"+current.variables.u_assignment_group); //Getting the correct group value from Variable - Eg. Allenton 95adf2dddb515b84f235591e5e961951

gr.query();
workflow.info(gr.getRowCount() + ' records retrieved'); // Getting no. of row count from the specifed group

while(gr.next()){
if((gr.getValue('user')) != (req_for)) // Restricting notification to Requested for, if user is already in the group
{
answer.push(gr.getValue('user').toString());
workflow.info("User value in While loop:"+gr.getValue('user').toString());
}
}

 

Any suggestions? 

 

Thanks in advance.

It worked, when i have changed the activity from Group to User.

 

Thanks.