- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2014 12:37 PM
I'm trying to add a role to all users who have a certain value for company. So I found the following wiki page script and I am trying to modify it but first of all I'm not sure where to put it for a one time on demand run. I trying putting in in a scheduled job, and a client script with no dice...
http://wiki.servicenow.com/index.php?title=Useful_User_Scripts
And here is my script...
var gr = new GlideRecord("sys_user");
gr.addQuery('company', 'Fulbright & Jaworski L.L.P.');
gr.query();
while(gr.next()) {
if (gr.accumulated_roles.toString().indexOf(",us_users,") == -1) {
gr.roles = gr.roles + ",us_users";
gr.update();
}
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2014 02:14 AM
company is a related record on the user form so you will need to use the sys_id of the company
change
gr.addQuery('company', 'Fulbright & Jaworski L.L.P.');
to
gr.addQuery('company', 'sys_id of the company');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2016 10:22 AM
I think accumulated roles is an old legacy field that doesn't do anything anymore. Marc