- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2018 02:01 PM
Hello,
I have a business rule with an advanced script. The BR is called by a reference type variable on a catalog item to filter the users only belonging to a specific group.
BUT, I want to filter only on users that are ALSO active. I have tried adding the addEncodedQuery method, but nothing is working for me. I am able to filter on the group members just fine with the variable reference qualifier:
javascript:"sys_idIN"+getGroupedUsers("IN","Hardware, Forensics").join(",")
My BR script is:
function getGroupedUsers(queryCondition, groupList) {
var groupListIds;
if (queryCondition && groupList) { groupListIds = getGroupListIds(groupList); }
var users = {};
var gr = new GlideRecord('sys_user_grmember');
if (groupListIds) { gr.addQuery('group', queryCondition, groupListIds); }
gr.query();
while (gr.next()) { users[gr.user.toString()] = true; }
var ids = [];
for (var id in users) { ids.push(id); }
return ids;
}
// get sys_ids for the named groups
function getGroupListIds(groupList) {
var ids = [];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('name','IN',groupList);
gr.query();
while (gr.next()) { ids.push(gr.sys_id.toString()); }
return ids;
}
Any assistance in additionally filtering on active users is greatly appreciated. Cheers, Mark S.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2018 07:30 AM
Did this answer your question? Please mark my response correct if it did. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2018 02:03 PM
gr.addQuery('user.active', true); right after your 'gr.addQuery('group')' line should do what you want.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2018 07:30 AM
Did this answer your question? Please mark my response correct if it did. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2018 02:16 PM
Hello Mark, many thanks, it was the 'user' bit I didnt get right in my attempts. Long time no hear, it was one of the first Knowledge conf in San Diego when we met - BC Lottery days. Cheers, Mark S.