- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 04:22 PM
Hi,
We have a group approval for Change Requests, this approval goes to the assignment group members for approval.
However what I would like to do is only for the approval to go to those members within the assignment group who have the role called "Change Approver" which I have created, I know I could create separate groups but I wish to avoid doing so.
Has anyone ever used such a script to do this and is it possible?
Any help appreciated.
Cheers.
Nabeel
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2017 02:20 PM
Hi Nabeel,
This is what i have tested and it works fine for me, are you having the required group assigned before workflow starts. I have just tested with this setup and it's working. I would have one 'Wait for Condition' to make sure assignment group is there before sending to approval, like below.
Please make sure you pass the correct sys_id of your role.
Result:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2017 09:40 AM
Hi Nabeel,
Please try with below if it helps, I have tested and it worked for me.
var answer = [];
var groupMemberships = new GlideRecord('sys_user_grmember');
groupMemberships.addQuery('group', current.getValue('assignment_group'));
groupMemberships.query();
while(groupMemberships.next()){
var user_sys_id = groupMemberships.getValue('user');
var hr = new GlideRecord('sys_user_has_role');
hr.addQuery('user', user_sys_id);
hr.addQuery('role', '2831a114c611228501d4ea6c309d626d'); //sys_id of role
hr.query();
if(hr.next())
{
answer.push(hr.getValue(user));
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2017 12:23 PM
Hi Shishir,
I've tried the script after changing the sys id of the role and now it seems to be skipping the approval altogether, I'm not sure why it's worked for you and not for me.
Sorry for troubling you I thought this would have been a lot more simple! If it helps I am on Helsinki.
Thanks again for your help so far I really appreciate it, I'm think the solution is close I just not sure why that script hasn't worked

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2017 01:03 PM
Sorry, i missed to put the user in quotes while copying the code here, updated the same. Please check.
Please try this:
var answer = [];
var groupMemberships = new GlideRecord('sys_user_grmember');
groupMemberships.addQuery('group', current.getValue('assignment_group'));
groupMemberships.query();
while(groupMemberships.next()){
var user_sys_id = groupMemberships.getValue('user');
var hr = new GlideRecord('sys_user_has_role');
hr.addQuery('user', user_sys_id);
hr.addQuery('role', '2831a114c611228501d4ea6c309d626d'); //sys_id of role
hr.query();
if(hr.next())
{
answer.push(hr.getValue('user'));
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2017 01:16 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2017 02:20 PM
Hi Nabeel,
This is what i have tested and it works fine for me, are you having the required group assigned before workflow starts. I have just tested with this setup and it's working. I would have one 'Wait for Condition' to make sure assignment group is there before sending to approval, like below.
Please make sure you pass the correct sys_id of your role.
Result: