- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 08:07 AM
Hello Community,
I have a problem in my current development that I couldn't crack.
1. I want to find all the users which has the view_changer role.
2. Problem is that view_changer role is contain in several roles, groups,etc.
Bottom line how can I find all the roles and group that contains view_changer role?
because thinking itil has the view_changer and admin has itil so at the end both admin and itil have the view_changer is there any easy way to do this on ServiceNow?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 08:52 AM
I just ran this and it seemed to work:
var gr = new GlideRecord('sys_user');
gr.addActiveQuery();
gr.query();
var count = 0;
var x = gr.getRowCount();
var curuser = gs.getUser();
while(gr.next()){
var user = curuser.getUserByID(gr.user_name);
if(user.hasRole('view_changer')){
gs.print("** " + gr.name + " has role");
count++;
}
}
gs.print("** Found " + count + " users out of " + x + " with role.");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 09:25 AM - edited 02-11-2025 09:26 AM
Find all roles that contain view_changer
Navigate to sys_user_role_contains.list and search for the role view_change
Find all groups that contain view_changer
Navigate to sys_group_has_role.list and search for the role view_change OR whatever roles you identified that contain the role
Find all users that have the view_change role
Navigate to sys_user_has_role.list and search for the role view_change OR whatever roles you identified that contain the role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 08:40 PM
share the script you are using
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader