- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2018 09:28 AM
I am hoping to automate servicenow group management using a catalog item. The item will only be available to itil users based on the category available for: The request has a reference field for the usr and reference field grp. The Approval process uses script to pull the group manager and if there is an error targets a specific Approval Error Override group. Currently the approval workflow path generates one catalog task to the servicenow admins. I would like to replace that with a script task. I have tried the following but it does not work and i am starting to think it is the write ACL on the sys_user_grmember table or maybe somethign I have overlooked in the script. We are using Service Portal as the only method for this request. Can I do this?
------------------------------------------- Workflow Script Action ---------------------------------
var usr = current.variables.user;
var grp = current.variables.group;
if(!usr.isMemberOf(grp))
{
var gr = new GlideRecord('sys_user_grmember');
gr.query();
gr.initialize();
gr.user = usr;
gr.group = grp;
gr.insert();
}
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2018 09:56 AM
Use this
var usr = current.variables.user;
var grp = current.variables.group;
if(!gs.getUser().getUserByID(usr).isMemberOf(grp)){
var gr = new GlideRecord('sys_user_grmember');
gr.initialize();
gr.user=usr;
gr.group=grp;
gr.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2018 10:15 AM
You bet! And community is the right place to start for learning 🙂