- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2017 05:49 PM
Hello,
I'm barely new to Reference Qualifiers and don't know if there's a way to filter the users table and only show the users that have the role "business_partner"
This is what I found when I searched for something:
javascript:"sys_idIN"+getRoledUsers("itil_admin").join(",")
But I really don't know how it works, that qualifier brings me all users that have at least one role from parent role to child roles
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2017 06:35 PM
getRoledUsers is an OOTB script (see Business Rule getRoledUsers)
// Return an array of sys_ids of the users that have at least one role
// optional parameters allow the exclusion (NOT IN) of some roles or
// look for specific roles (IN)
//
// optional: queryCondition - 'IN' or 'NOT IN'
// optional: roleList - a comma separated list of role names
//
function getRoledUsers(queryCondition, roleList) {
var roleListIds;
if (queryCondition && roleList) {
roleListIds = getRoleListIds(roleList);
}
var users = {};
var gr = new GlideRecord('sys_user_has_role');
if (roleListIds) {
gr.addQuery('role', queryCondition, roleListIds);
}
gr.query();
while (gr.next()) {
users[gr.user.toString()] = true;
}
var ids = [];
for (var id in users)
ids.push(id);
return ids;
}
So, the syntax your are looking for is
javascript:'sys_idIN' + getRoledUsers('IN','itil_admin').join(",");
No need for custom code
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-01-2018 05:50 PM
Look at line 18:
gr.addQuery('role', queryCondition, roleListIds);
Check out the API reference for addQuery
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022