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

I see you! My issue is the inability to write advanced scripts. I agree, it sounds like what we need would go in that spot and would say something like if user = group.manager, don't generate that user's approval..


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'));


}


I tried this both using a User Approval activity and a Group Approval activity and both still generated an approval for the group manager. Does this look correct?



find_real_file.png


I have a similar requirement, where I am trying to exclude user submitting request, does the below code work for the same.

 

answer = [];

 

var gr= new GlideRecord('sys_user_grmember');

 

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

 

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

 

gr.query();

 

while(gr.next()){

 

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

 

}

I don't see why not.