- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2018 09:02 AM
I need to pull from a Change_Approver group that contains all managers, and a Change_Approver_Delegates group that I must limit to the delegated approvers for the same department as the assigned_to in the current change request.
I'm using a script include to pull the members of the Change Approver group put I need to pull from two assignment groups and put the additional restriction of the same department on the delegates group.
Here is a sample of what i have but I am having trouble getting the script include to pule from two groups
javascript: new ACMEUserGroupUtils().getGroupMembers(gs.getProperty('change.approval.groups'), current.assigned_to) + "^department=" +current.assigned_to.department
script include below
var ACMEUserGroupUtils = Class.create();
ACMEUserGroupUtils.prototype = {
initialize: function() {
},
/*
getGroupMembers() function returns the list of the group members of the
groupName passed as a parameter.
*/
getGroupMembers: function(groupName, excludeUsers) {
var answer = [];
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group.name', groupName);
grMember.query();
if (excludeUsers != '') {
while (grMember.next()) {
if (excludeUsers.indexOf(grMember.user.toString()) == -1) {
answer.push(grMember.user.toString());
}
}
}
return 'sys_idIN' + answer.toString();
},
/*
isUserInGroup(): returns the user only if the user is a member of the group, empty otherwise.
Note: does not return boolean as function name would suggest.
*/
isUserInGroup: function(user, group) {
//returns user if they are a mmember of the group.
var answer = '';
if (gs.getUser().getUserByID(user).isMemberOf(group)) {
answer = user;
}
return answer;
},
type: 'ACMEUserGroupUtils'
};
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2018 02:47 PM
Use this
javascript: new ACMEUserGroupUtils().getGroupMembers('Change_Approvers', current.requested_by) +'^OR'+ new ACMEUserGroupUtils().getGroupMembers('Change_Approver_Delegates', current.requested_by) + "^department=" + current.assigned_to.department
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2018 09:25 AM
Hi,
I think there a
var answer ='';// [];
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group.name', groupName);
grMember.query();
if (excludeUsers != '') {
while (grMember.next()) {
if (excludeUsers.indexOf(grMember.user.toString()) == -1) {
answer+=grMember.user.toString()+',';
// answer.push(grMember.user.toString());
}
}
}
return 'sys_idIN' + answer.toString();
Hope this will help
Please Hit ✅Correct, ⭐️Helpful depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2018 02:51 PM
This looks like it should work
But when I tried to call this script include in my reference qualifier below, it appears the the list just ignored the reference qualifier and displayed all users in sys_user
Here is my reference qualifier
javascript: new USAAChangeApprovers().getGroupMembers(Change_Approvers, current.assigned_to).
I am just putting the name of the group for the variable for groupName in the function. Is that correct or do I need to be putting something else in the variable name?
Thanks again for your help

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2018 06:17 PM
your Script Include name is : ACMEUserGroupUtils so you have to use
javascript: new ACMEUserGroupUtils().getGroupMembers(Change_Approvers, current.assigned_to).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2018 10:17 AM
Actually I was testing a new script include....but this is the one I'm currently using
javascript: new ACMEUserGroupUtils().getGroupMembers(gs.getProperty('change.approval.groups'), current.requested_by)
The one above is actually calling the 'change.approval.groups' from the Change Properties file (I hope I am reading this correctly.
I would like to put the Change_Approves group directly into the reference qualifier without calling the gs.getProperty glide script. because I need to use this script include for another group
I put the Change_Approvers group directly into the reference qualifier like this...
javascript: new ACMEUserGroupUtils().getGroupMembers(Change_Approvers, current.requested_by)
and it completely ignores the script include and delivers all members of sy_user...it even ignores the exclude portion of the scrip so it looks like the entire script include in crashing...I don't remember how to use the debugging tool.
The script include is looking for groupName as a parameter (See below)
/*
getGroupMembers() function returns the list of the group members of the
groupName passed as a parameter.
*/
getGroupMembers: function(groupName, excludeUsers) {
How do a enter the groupName in the reference qualifier like I entered current.requested_by ? Am i missing some annotation before the groupName Change_Approvers like var or something?
Please Help...and thanks