Add Multiple users into a group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Did someone manage to add multiple users into an Active Directory group using the Out of the box action "Add Users to Group".
I have a simple catalog item, which has a list collector, and i see that there is an AD activity for that, what should be in the highlighted variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The User Names field expects an array of string values — specifically, an array of AD usernames (sAMAccountName values), not sys_ids.
The challenge is that a list collector variable stores comma-separated sys_ids, so you can't drag it directly into that field. You need to transform it first.
Here's the approach:
1. Add a Script Step before the "Add Users to Group" action that converts the list collector sys_ids into an array of AD usernames:
(function execute(inputs, outputs) {
var sysIds = inputs.list_collector_value.toString().split(',');
var userNames = [];
for (var i = 0; i < sysIds.length; i++) {
var gr = new GlideRecord('sys_user');
if (gr.get(sysIds[i].trim())) {
userNames.push(gr.getValue('user_name')); // sAMAccountName
}
}
outputs.ad_usernames = userNames;
})(inputs, outputs);
In the script step, define the output variable ad_usernames as type Array.String.
2. Then drag the ad_usernames pill from your script step's output into that highlighted User Names field. It will satisfy the array.string requirement.
3. Group Name should be the AD group's distinguished name or name, which you already seem to have mapped.
The key takeaway is that the OOB action does support multiple users — that's exactly what the array.string input is for — but you need that intermediate script step to bridge the gap between the list collector (comma-separated sys_ids) and the AD action (array of username strings).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi Naveen,
great insights, with your message 'dd a Script Step before the "Add Users to Group" action', you mean that I should create a custom action? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
So,
I kept trying and follow your steps as follow:
Script:
output:
In the flow:
In the logs, i can see that it is finding the right emails (same as user_name) for us, but i still cant add the users in the group.
I get the following error for the Add users to Group:
{
"Action Status": {
"code": 1,
"message": "Error: Invalid User Name : Leandre.Mundere@xxxxxxxx.com (Process Automation.f83ed243873151107701ed3e0ebb35bd; line 39)"
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi Naveen,
great insights, with your message 'dd a Script Step before the "Add Users to Group" action', you mean that I should create a custom action?
