Automatically remove user from group
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2013 08:31 AM
Hello,
I am trying to build an automated user remove catalog request in ServiceNow and am having trouble with the script part.
A user will fill out a form with:
User's name - variable = group_members
Group to be removed from - variable = workgroup
I want to user a GlideRecord to search for that user and remove him/her from the group.
I have been using the below and cannot get it to work. Any ideas?:
var rec = new GlideRecord('sys_user');
rec.addQuery('sys_id', current.variables.group_members);
rec.query();
while (rec.next())
{
var rec1 = new GlideRecord('sys_user_grmember');
rec1.addQuery('sys_id', current.variables.workgroup);
rec1.query();
while (rec1.next())
{
rec1.deleteRecord();
}
}
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2013 07:08 AM
Thank you all for the help!