- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2022 10:26 PM
I have to assign a "single same role"(e.g : itil) to 1000 users in a single time. How can I do that. any help would be appreciated.
Solved! Go to Solution.
- Labels:
-
Cost Management (ITSM)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2022 10:32 PM
Hi
Adding users > groups > roles is best practice. Adding roles directly to users is bad practice in ServiceNow.
add users to group and then assign the role to group. now you just need to add users to that group , this way all those users will have role.
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2022 10:31 PM
Hi there,
Is this a one time thing or should you do this more often?
My first through would be writing a small Fix Script.
Question:
Why mentioning adding a role? Adding roles directly, is bad practice. Consider adding those users to a group instead.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2022 10:32 PM
Hi
Adding users > groups > roles is best practice. Adding roles directly to users is bad practice in ServiceNow.
add users to group and then assign the role to group. now you just need to add users to that group , this way all those users will have role.
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2022 10:35 PM
Hi,
I would suggest you to create a group, add users to that group and assign the role to group.
Here is the script to add multiple users to group.
var group_sys_id = '<group_sys_id>'; // your group sysid
var users = new GlideRecord('sys_user');
users.addActiveQuery(); // brings all active records
users.addEncoddedQuery("add-your-query-here");
users.query();
while (users.next()) {
var members = new GlideRecord('sys_user_grmember');
members.addEncodedQuery('group=' + group_sys_id + '^user=' + users.sys_id);
members.query();
if (members.getRowCount() == 0) {
members.initialize();
members.group = group_sys_id;
members.user = users.sys_id;
members.insert();
}
}
Thanks!
Sagar Pagar