Display users NOT belonging to specific group in a catalog variable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 10:39 PM
Hello,
For a catalog item, I have a requirement to display members not belonging to a specific group on a catalog variable referencing to sys_user table.
I have written the below global not client callable script include as -
var getNonItilUsers = Class.create();
getNonItilUsers.prototype = {
initialize: function() {},
getUser: function() {
var userName = [];
var users = new GlideRecord('sys_user');
users.addActiveQuery();
users.query();
while (users.next()) {
var userGroup = new GlideRecord('sys_user_grmember');
userGroup.addQuery('user', users.sys_id);
userGroup.addQuery('group','a671c95edb875910cb183632f39619bf');
userGroup.query();
if (!userGroup.hasNext()) {
userName.push(users.getDisplayValue());
}
return userName
}
},
type: 'getNonItilUsers'
};
On the variable advanced reference qualifier, i have defined as -
javascript:new getNonItilUsers().getUser();
However, the variable displays users belonging to the group which i sys_id'ed when testing the catalog item.
Note: To test the script include, I ran it in a background script using gs.print(users.getDisplayValue()), and it works fine.
Can you please let me know what i am doing wrong to achieve this scenario?
Thanks,
Somujit
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 06:23 PM - edited 09-22-2024 06:25 PM
I tried the script as shared with you. However, the reference variable dropdown is not restricting the users belonging this group form being displayed, and is displaying all the users.
Below is the script include and variable advance ref qualifier -
Thanks