- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2022 05:18 AM
How to list out the users with no roles just like (Abel Tuter) in servicenow Learning Platform?
Solved! Go to Solution.
- Labels:
-
User Experience and Design

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2022 05:25 AM
Hello Tejas,
you can use the below fix script to get the users list who do not have any roles
var gr3 = new GlideRecord('sys_user');
gr3.query();
while(gr3.next())
{
var gr2 = new GlideRecord('sys_user_has_role');
gr2.addQuery('user',gr3.sys_id);
gr2.query();
if(!gr2.next())
{
gs.print('User Name is(No role) : ' + gr3.name);
}
}
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2022 05:21 AM
Hi,
Check this -
https://community.servicenow.com/community?id=community_article&sys_id=7c00ca90db5ec450d58ea345ca9619c5
Or in script form something like this -
var ans=[];
var user = new GlideRecord('sys_user');
user.addEncodedQuery('active=true^sys_id!=javascript:getRoledUsers();');
user.query();
while(user.next())
{
ans.push(user.name+''); // to get list of user names . else pass user.sys_id to get sysids
}
gs.info(ans.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2022 09:32 PM
Thank You.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2022 05:25 AM
Hello Tejas,
you can use the below fix script to get the users list who do not have any roles
var gr3 = new GlideRecord('sys_user');
gr3.query();
while(gr3.next())
{
var gr2 = new GlideRecord('sys_user_has_role');
gr2.addQuery('user',gr3.sys_id);
gr2.query();
if(!gr2.next())
{
gs.print('User Name is(No role) : ' + gr3.name);
}
}
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2022 09:32 PM
Thank You.