Script to add users to a group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:48 PM
I wanted to write a script where we get each user from sys_user table and check if they have a manager, if yes, then add the manager to a group.
Can someone help me with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:59 PM
Hello @Aishwarya Selv1
var gr = new GlideRecord('sys_user');
gr.addQuery();
while(gr.next()){
if(gr.manager !=""){
// adding logic into group
}
}
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 01:14 AM
Hello @Aishwarya Selv1 ,
Please refer to this : https://www.servicenow.com/community/now-platform-forum/query-all-managers-add-to-group/m-p/1134486
@Aishwarya Selv1, Please mark my answer as "Accept as Solution" and "Helpfuls." If it works for you.
Thank you!