- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 04:50 AM
Hi All,
I want to find out the users who has roles in their profile but with No groups.
We are planning to remove that roles from that users and we will assign them the groups.
There are around 1 lakh active users in our user table.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 05:44 AM
Hi @Avinash72 ,
You can create a fix script or you can run the below script in "script -background" it will give you the list of user name who has role but not group,
var user = new GlideRecord('sys_user');
user.addActiveQuery();
user.query();
while(user.next()){
var grRole = new GlideRecord ('sys_user_has_role');
grRole.addQuery('user', user.sys_id);
grRole.query();
if(grRole.hasNext()){
var grmember = new GlideRecord('sys_user_grmember');
grmember.addQuery('user', user.sys_id);
grmember.query();
if(!grmember.hasNext()){
gs.print(user.getDisplayValue());
}
}
}
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 05:44 AM
Hi @Avinash72 ,
You can create a fix script or you can run the below script in "script -background" it will give you the list of user name who has role but not group,
var user = new GlideRecord('sys_user');
user.addActiveQuery();
user.query();
while(user.next()){
var grRole = new GlideRecord ('sys_user_has_role');
grRole.addQuery('user', user.sys_id);
grRole.query();
if(grRole.hasNext()){
var grmember = new GlideRecord('sys_user_grmember');
grmember.addQuery('user', user.sys_id);
grmember.query();
if(!grmember.hasNext()){
gs.print(user.getDisplayValue());
}
}
}
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 06:38 AM
Go to sys_user_has_role , select "Inherited" from Personalized List. Filter out "true" from Inherited. Now you have a list of users who didn't get roles from groups.