- 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 09:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2020 09:11 AM
Hi,
You are welcome.
Just for information.
group -> would check against sys_id
group.name -> would check against name
if you query for group.name then you need to give current.assignment_group.name
if you query for group then you need to give sys_id
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-14-2020 03:10 AM
Hi Ankur,
I have used your script in one of my group approvals, But still the approval is triggering to that user.Please find the below script.
// Set the variable 'answer' to a comma-separated list of group ids or an array of group ids to add as approvers.
answer = [];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group','2afc7336db6e805049df7ffb8c961978');
var isMember = gs.getUser().getUserByID(current.request).isMemberOf('2afc7336db6e805049df7ffb8c961978');
if(isMember == true){
gr.addQuery('user','!=',current.request);
}
gr.query();
while(gr.next()){
answer.push(gr.getValue('user'));
}
// For example:
// var answer = [];
// answer.push('id1');
// answer.push('id2');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2020 03:25 AM
Hi,
I assume this workflow is on incident table so current object means incident record.
Also I assume you want to check for the current assigned to user
So please update as below
// Set the variable 'answer' to a comma-separated list of group ids or an array of group ids to add as approvers.
answer = [];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group','2afc7336db6e805049df7ffb8c961978');
var isMember = gs.getUser().getUserByID(current.assigned_to).isMemberOf('2afc7336db6e805049df7ffb8c961978');
if(isMember == true){
gr.addQuery('user','!=',current.assigned_to);
}
gr.query();
while(gr.next()){
answer.push(gr.getValue('user'));
}
// For example:
// var answer = [];
// answer.push('id1');
// answer.push('id2');
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-14-2020 03:47 AM
No Ankur,
This workflow is in SC_REQ_ITEM table.
Actually my scenario is, in my catalog item i have a variable called req_for. and i have an approval group in the catalog item. If suppose i select requested_for user any member in that group. Approvals should trigger all members expect the select req_for user