
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2018 06:00 PM
Hi, I am currently creating a catalog request to have our users request access to a ServiceNow assignment group through a form on the catalog and add this to their ServiceNow user account. I don't know what activity I can use in a workflow to automate this. We currently have Orchestration enabled. What would be the best way to accomplish this?
Thanks
-Julio
Solved! Go to Solution.
- Labels:
-
Orchestration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2018 05:11 PM
Try this
var grpArr = current.variables.groups.toString().split(',');
for (var i=0;i<grpArr.length;i++)
{
var grm = new GlideRecord('sys_user_grmember');
grm.addQuery('group',grpArr[i]);
grm.addQuery('user',current.variables.requested_for);
grm.query();
if (!grm.next())
{
grm.group =grpArr[i];
grm.user = current.variables.requested_for;
grm.insert();
}
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2018 10:14 AM
You can do something like this
var grpArr = current.variables.groups.toString().split(',');
for (var i=0;i<grpArr.length;i++)
{
var grm = new GlideRecord('sys_user_grmember');
grm.initialize();
grm.groups =grpArr[i];
grm.user = current.variables.requested_for;
grm.insert();
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2018 03:20 PM
Thanks, this almost worked. When I add groups they show up empty on the users profile. Any ideas? I can see that 3 groups are added to the users account but the names are blank for each group.
Thanks
-Julio

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2018 04:00 PM
correction to the script
var grpArr = current.variables.groups.toString().split(',');
for (var i=0;i<grpArr.length;i++)
{
var grm = new GlideRecord('sys_user_grmember');
grm.initialize();
grm.group =grpArr[i];
grm.user = current.variables.requested_for;
grm.insert();
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2018 04:40 PM
Awesome this worked. The only issue I have now is if the user already has the group and they request it again, this adds the group twice. How do I check if they have the group already added?
Thanks
-Julio

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2018 05:11 PM
Try this
var grpArr = current.variables.groups.toString().split(',');
for (var i=0;i<grpArr.length;i++)
{
var grm = new GlideRecord('sys_user_grmember');
grm.addQuery('group',grpArr[i]);
grm.addQuery('user',current.variables.requested_for);
grm.query();
if (!grm.next())
{
grm.group =grpArr[i];
grm.user = current.variables.requested_for;
grm.insert();
}
}
Please mark this response as correct or helpful if it assisted you with your question.