Setting Display Field on List Collector in Service Portal

jmiskey
Kilo Sage

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

1 ACCEPTED SOLUTION

jmiskey
Kilo Sage

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()

 

View solution in original post

6 REPLIES 6

Priyanka Gupta
Mega Guru

Did you try setting the display:true of the field you want on the list view?

Also, you can go to the table-> related links -> layout list and select the right fields to be displayed in the list view.

find_real_file.png

find_real_file.png

Hope this helps.

I already have the List Layout set up like that, so that did not make a difference.

I thought about setting the Display field directly on the Table itself, but have been cautioned about customizing settings on out-of-the-box tables.  So I was hesitant to try that.  I tried it, and it does work, but is there any danger in doing this?  Will future upgraded change the Display Value back to False?

Ahh, now that I think about it, it is going to make a difference. Sorry I suggested that in the first place. If you set the display:true for the User field on the Groups table, everywhere this table is being used as a reference, the users would only see the User field. Not good at all since they are looking for Group information.

It would be helpful if you can post a screenshot of where you are at with this.