- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 06:19 AM
I am trying to create a way for an incident to be reviewed by a peer on the team before it can be resolved. I went with the out of the box group approval, but the issue is that the person requesting the approval (the person assigned to work the ticket) is also part of the group that has to approve the request. So then they get a approval request for their own approval, which makes them able to approve their own approval request. I'd assume ServiceNow had an easy way to not include the person in the group approval if they were part of the team. Anyone know of a quick way to do this?
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 09:02 AM
Hi Rocky,
please check updated script
you were querying with group.name but giving sys_id so updated code below
answer = [];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group', current.assignment_group);
var isMember = gs.getUser().getUserByID(current.assigned_to).isMemberOf(current.assignment_group);
if(isMember == true){
gr.addQuery('user','!=',current.assigned_to);
}
gr.query();
while(gr.next()){
answer.push(gr.getValue('user'));
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 07:09 AM
Hi,
Find the similar thread that might help you.
Mark helpful or correct based on impact.
Regards,
Priyanka A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 07:19 AM
I don't think it would be something OOB.
you will have to script it out.
Use Approval User Activity and script it like this so that it skips the current assigned to user
answer = [];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group.name', 'Group ABC');
// check if assigned_to user is member of that group ABC
// if yes then exclude that user
var isMember = gs.getUser().getUserByID(current.assigned_to).isMemberOf('Group ABC');
// if you want to check for assigned_to user is member of current ticket assignment group then do this
var isMember = gs.getUser().getUserByID(current.assigned_to).isMemberOf(current.assignment_group);
if(isMember == true){
gr.addQuery('user','!=',current.assigned_to);
}
gr.query();
while(gr.next()){
answer.push(gr.getValue('user'));
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 08:48 AM
Hi
When I run the script using an Approval - User activity, I do not get any approvals generated. I think the issue is that the "assignment_group" might be returning null?
Below is the script I am running:
answer = [];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group.name', current.assignment_group);
var isMember = gs.getUser().getUserByID(current.assigned_to).isMemberOf(current.assignment_group);
if(isMember == true){
gr.addQuery('user','!=',current.assigned_to);
}
gr.query();
while(gr.next()){
answer.push(gr.getValue('user'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 09:02 AM
Hi Rocky,
please check updated script
you were querying with group.name but giving sys_id so updated code below
answer = [];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group', current.assignment_group);
var isMember = gs.getUser().getUserByID(current.assigned_to).isMemberOf(current.assignment_group);
if(isMember == true){
gr.addQuery('user','!=',current.assigned_to);
}
gr.query();
while(gr.next()){
answer.push(gr.getValue('user'));
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader