Add Multiple users into a group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours 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
2 hours 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).
