need to populate assignment group members in list collector field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 03:30 AM
Hi all,
I have group field(reference to group) when i select any group, that group members need to populate in list collector field(List collector reference to user ).
i want to show that particular group members in list collector field remaining group users i want to restrict...
Thanks in advance...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 03:35 AM
Hi Lata,
Do you want this to run when record is inserted/updated? if yes then you can use before insert/update BR
sample script below
var currentGroup = current.assignment_group;
var arr = [];
var members = new GlideRecord('sys_user_grmember');
members.addQuery('group', currentGroup);
members.query();
while(members.next()){
arr.push(members.getValue('user'));
}
current.<list_field> = arr.join(',');
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 03:37 AM
Hi Lata,
Is this on a cataolg item? If so, we have had this need and did the following. In the list collector reference qual, reference a script include that returns the required information. As an example
Below is the script include that is used
var GetGroupMembers = function() {
var answer = ' ';
var group = current.variables.group_name; //name of variable on catalog item to use as group reference.
var group_members = new GlideRecord('sys_user_grmember');
group_members.addQuery('group',group);
group_members.query();
while (group_members.next()) {
if (answer.length > 0) {
answer += (',' + group_members.user.sys_id);
} else {
answer = group_members.user.sys_id;
}
}
return 'sys_idIN' + answer;
};

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 09:15 AM
Hi, Checking in on whether my reply resolved your issue? If so please Mark ✅ Correct and /or 👍 Helpful if you find my response worthy based on the impact.
By doing so you help other community members find resolved questions which may relate to an issue they're having.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2022 04:29 AM
This worked perfectly for a client-side deployment, thank you.