- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2014 12:13 PM
Does anyone have an example script I can use to add a role to a group. I need to add this as a clone script and I am having a hard time finding any examples to get started with. Basically just need to add the 'admin' role to a group called 'CS-ServiceNow Administrators'. Any help would be greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2014 12:20 PM
var role = new GlideRecord('sys_group_has_role');
role.initialize();
role.group = '<sys_id of group>';
role.role = '<sys_id of admin role>';
role..inherits = true;
role.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2014 12:20 PM
var role = new GlideRecord('sys_group_has_role');
role.initialize();
role.group = '<sys_id of group>';
role.role = '<sys_id of admin role>';
role..inherits = true;
role.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2014 12:32 PM
That's exactly what I needed, thank you so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 07:20 PM
Mike, I used this below script to add users to a group if they are from a particular location.
var user = new GlideRecord('sys_user');
if(user){
user.addQuery('location','57fd7b993790200044e0bfc8bcbe5d19');
user.query();
//var currentUser = user.getDisplayValue();
while(user.next()) {
var member = new GlideRecord('sys_user_grmember');
member.initialize();
member.user = user.name.getDisplayValue();
member.group = 'b85d44954a3623120004689b2d5dd60a';
member.insert();
}
Is there a way to ignore the users that are already added to that group & make sure only new users are added ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2014 09:42 AM
So I have this running on a Clone - Cleanup Script. Does anyone know how to make it only run when the clone is to a certain environment? So basically have it running after a clone if the clone is to our dev instance.