Report on the users with no roles and groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2025 09:50 AM
I need to pull a report of users with no roles and no groups.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2025 01:55 AM
you can create a client callable script include which is classless and use this script
Then in report filter condition call it like this
SysId [IS ONE OF] javascript: usersWithNoRoleNoGroup();
function usersWithNoRoleNoGroup() {
var usersWithoutRolesOrGroups = [];
var userGR = new GlideRecord('sys_user');
userGR.addActiveQuery(); // Only check active users
userGR.query();
while (userGR.next()) {
// Check for roles associated with the user
var roleGR = new GlideRecord('sys_user_has_role');
roleGR.addQuery('user', userGR.sys_id);
roleGR.query();
// Check for groups associated with the user
var groupGR = new GlideRecord('sys_user_grmember');
groupGR.addQuery('user', userGR.sys_id);
groupGR.query();
if (!roleGR.hasNext() && !groupGR.hasNext()) {
// Add user details to the array if they have no roles and no groups
usersWithoutRolesOrGroups.push(userGR.getUniqueValue());
}
}
return usersWithoutRolesOrGroups.toString();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2025 03:47 AM
This script looks familiar ; )
Good to hybrid a solution and good call out @Ankur Bawiskar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 08:52 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2025 08:15 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2025 11:55 PM
You can put a related list condition, below is an example for roles, you can select "None" in the quantity and then select the related list as roles, same can be done for groups