Display members of Assignment Group in form variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2019 11:09 AM
I am trying to get a variable field on a form to display the members of an Assignment Group. I can set a reference field to the SYS_USER_GROUP table and get all of the Assignment Group names to appear but I don't know how to get the list of members in the group to display instead. Looking at Assigned To it is dependent on Assignment Group and references the SYS_USER from the TASK table.
So I set the reference field to SYS_USER with an advanced qualifier of assignment_group=sys ID of the assignment group^EQ but that isn't working either.
I guess I'm not sure how to get this to display correctly. Maybe user something other than a reference field (Lookup select box?)? I shouldn't need a big block of code to do this.
- 3,976 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2019 11:39 AM
I assume this is for a catalog item
In 'Type Specification' section of your group member catalog variable, reference to user table add reference qualifier as below
javascript: new groupmembers ().members(current.variables.your group);
Script include:
var groupmembers = Class.create();
groupmembers .prototype = {
initialize: function() {
},
members: function(groupID){
var grpmem= '';
var RelGR = new GlideRecord('sys_user_grmember');
RelGR.addEncodedQuery('group='+groupID);
RelGR.query();
while (RelGR.next()) {
if (grpmem.length > 0) {
grpmem= grpmem+','+RelGR.user.sys_id;
}
else {
grpmem= ''+RelGR.user.sys_id;
}
}
return 'sys_idIN' + grpmem;
},
This will display all the group members
Hope this helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2020 04:05 PM
Curious, did you ever get this to work with a qualifier? I wouldn't think it should take a script include to get this working. Hope to hear from you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2020 12:21 AM
I had the similar requirement.
I have variables in the catalog item,
1. 'Add/Remove the users to the Existing Group' with drop down options "Add Members" and "Remove Members".
2. Group Name (reference to Groups table)
I have List Collector variable called "Group Members" to show the list of users, if user selects "Add Members" then show all users which are not part of the group selected and if user selects "Remove Members" then show only members part of the group selected.
Call the script include from Variable Reference qualifier as below;
javascript: new yourScriptIncludeName().showGroupMembersBasedOnAddOrRemoveVariable(current.variables.existing_add_remove_members, current.variables.existing_group_name)
Script Include Code;
showGroupMembersBasedOnAddOrRemoveVariable: function(valueAddOrRemove, groupName) {
var refQualQuery = "active=true";
if(valueAddOrRemove == 'Add Members'){
return refQualQuery + "^sys_idNOT IN " + this._grGroupMembers(groupName);
}
else if(valueAddOrRemove == 'Remove Members'){
return refQualQuery + "^sys_idIN " + this._grGroupMembers(groupName);
}
},
_grGroupMembers: function(groupName){
var grGrpMembers = new GlideRecord('sys_user_grmember');
grGrpMembers.addQuery('group', groupName);
grGrpMembers.query();
var listOfUsers = [];
while(grGrpMembers.next()){
listOfUsers.push(grGrpMembers.user.toString());
}
return listOfUsers;
},
Hope this helps.
Please Mark correct or helpful based on response.
Thanks, Mittal.