- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2019 11:22 AM
So I am creating a form where managers can request to have members removed from Groups. So, when they select a Group, I want a List Collector populated with the members of that Group, so the List Collector is based on the Group Member table (sys_user_grmember). It looks like this field does NOT have a Display Field set in the Table Design. The List Collector on my Service Portal form seems to be defaulting to showing the system creation date field, which isn't very helpful.
How can I change this to show the User field from the Group Member table? I tried using Variable Attributes, but that did not seem to work.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 07:40 AM
OK, I figured out a solution coming at this from a different angle.
Instead of using the Group Member table as my reference table for my List Collector variable, I used the User (sys_user) table. I then used a function in a Script Includes to build the Reference Qualifier that I need. So, the Script Includes look like this:
var GroupMembersCriteria = Class.create();
GroupMembersCriteria.prototype = {
initialize: function(){
},
allGroupMembers:function(){
//Only return active users who are members of selected Group
//get selected Group from SC Variable
var include = '';
var selectedGrp2 = current.variables.group;
//return all members of selected group
var users2 = new GlideRecord('sys_user_grmember');
users2.addQuery('group', selectedGrp2);
users2.query();
//write all members user sys_ids to string
while(users2.next()) {
include += (',' + users2.user);
}
//return criteria string
return 'sys_id IN' + include + '^active=true^user_nameISNOTEMPTY';
},
type: 'GroupMembersCriteria'
};
And then call that from the Reference Qualifier on the List Collector variable like this:
javascript:new GroupMembersCriteria().allGroupMembers()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 06:09 AM
OK. This is where I am at now. I added the following Variable Attribute:
ref_ac_columns=user,ref_ac_columns_search=true,ref_auto_completer=AJAXTableCompleter,ref_ac_order_by=user
It now two fields, the Created On Date field, and the User field. So I at least see the field I want, and this extra unwanted field. However, after selecting records, it just shows the Created On Date field, i.e.
I would like to change that to show the User name instead.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 07:40 AM
OK, I figured out a solution coming at this from a different angle.
Instead of using the Group Member table as my reference table for my List Collector variable, I used the User (sys_user) table. I then used a function in a Script Includes to build the Reference Qualifier that I need. So, the Script Includes look like this:
var GroupMembersCriteria = Class.create();
GroupMembersCriteria.prototype = {
initialize: function(){
},
allGroupMembers:function(){
//Only return active users who are members of selected Group
//get selected Group from SC Variable
var include = '';
var selectedGrp2 = current.variables.group;
//return all members of selected group
var users2 = new GlideRecord('sys_user_grmember');
users2.addQuery('group', selectedGrp2);
users2.query();
//write all members user sys_ids to string
while(users2.next()) {
include += (',' + users2.user);
}
//return criteria string
return 'sys_id IN' + include + '^active=true^user_nameISNOTEMPTY';
},
type: 'GroupMembersCriteria'
};
And then call that from the Reference Qualifier on the List Collector variable like this:
javascript:new GroupMembersCriteria().allGroupMembers()