
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â05-28-2024 08:26 AM
I have a User Reference variable on a catalog item. The BU does not want their names to be in the list of users. I created a script include:
filterOutByGroupName: function(group_name) {
/* Will remove users of the specified group from the list */
var found_users = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group.name", group_name);
gr.addNotNullQuery("user");
gr.query();
while (gr.next()) {
found_users.push(gr.user.sys_id.toString());
}
var ref_qual = "sys_idNOT IN" + found_users.join(",");
return ref_qual;
},
And I have added this to the Advanced Ref Qual:
javascript: new UserFilterUtils.filterOutByGroupName('Reporting');
But, I am still getting the users from that group in the list. What am I doing wrong?
Thank you, Charles
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â05-28-2024 12:47 PM
Hi @cgedney,
Didn't go through the entire code but looks like it's missing a set of parenthesis
i.e.
new UserFilterUtils().filterOutByGroupName('Reporting');
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â05-28-2024 08:46 AM
Hi @cgedney
You can change the below line :
var ref_qual = "sys_idNOT IN(" + found_users.join(",") + ")";
Thanks and Regards
Sai Venkatesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â05-28-2024 10:38 AM
It is still showing the members of that group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â05-28-2024 10:49 AM
Hi @cgedney
You can write the script include and call the script include as reference qualifier in the variable you needed.
change the values based upon your Requirement.
var rolesfilter = Class.create();
rolesfilter.prototype = {
initialize: function() {
},
getRoles: function() {
var userID = gs.getUserID();
gs.info("The userID is: " + userID);
var userRoleGR = new GlideRecord('sys_user_has_role');
userRoleGR.addQuery('user', userID);
userRoleGR.query();
var roles=[];
while (userRoleGR.next()) {
roles.push(userRoleGR.sys_id.toString());
}
gs.info("roles are"+roles);
return 'sys_idIN'+roles;
},
type: 'rolesfilter'
};
and in advance Reference Qualifier add this :
javascript:new rolesfilter().getRoles();
Thanks and Regards
Sai Venkatesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â05-28-2024 12:24 PM
I checked and I do have Client callable selected and the Script Include is active, but I am getting this error message:
com.glide.script.RhinoEcmaError: undefined is not a function.
<refname> : Line(1) column(0)
==> 1: new UserFilterUtils.filterOutByGroupName('Reporting');