Populate the members of the group in a variable Dynamically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 05:50 AM
Hello Everyone,
I am trying to auto populate members of the groups in a variable based on other variable choices.
EX: We have 2 variable V1 and V2
V1 has 3 choices
Choices: TYPE1, TYPE2, TYPE3.
This Variable and the choices are not dependent to the V2 groups.
When V1 is selected as = TYPE1
the Variable V2 should show the list of group members who are part of group "Group1"
When V1 is selected as = TYPE2
the Variable V2 should show the list of group members who are part of group "Group2"
When V1 is selected as = TYPE3
the Variable V2 should show list group members who are part of group "Group 3"
Please help me with this functionality.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 03:11 AM
Hi @Insider ,
Please find the below and see if it helps you in any way.
Client Callable AJAX Script:
var MyScriptInclude = Class.create();
MyScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getMemberIDs: function(valueV1) {
var grp;
switch (valueV1) {
case 'TYPE1':
grp = 'SYS ID of Group1';
break;
case 'TYPE2':
grp = 'SYS ID of Group2';
break;
case 'TYPE3':
grp = 'SYS ID of Group3';
break;
default:
grp = '';
break;
}
var memberSysIDs = [];
if (grp) {
var memgr = new GlideRecord('sys_user_grmember');
memgr.addQuery('group', grp);
memgr.query();
while (memgr.next()) {
memberSysIDs.push(memgr.user.sys_id.toString());
}
}
return memberSysIDs.join(',');
},
type: 'MyScriptInclude'
});
Usage in Variable V2:
javascript:'active=true^sys_idIN' + new MyScriptInclude().getMemberIDs(current.variables.V1VariableName);
Please my answer correct and helpful.
Best regards,
Kanhaiya