How to increase the maximum size of a list collector?

david_williams1
Kilo Expert

Hey folks,

We have an item for users to request a new distribution group on our service portal, which includes a list collector on the users table to specify which users should be added to the group.

I'm setting up a button so that managers can add all users who report to them to the variable with one click. As this is service portal, I'm using a macro variable which points at a widget to do the work. Server side gets the list of users with a recursive function, then client side writes it into the variable on the form. It's working well in most cases, but when I try it on a user with a lot of reports (more than about 30), the script doesn't seem to be able to write to the list collector variable. For testing I wrote it to a multi-line text variable and it's coming up with a comma seperated list of however many user sysIDs it's supposed to have, no problems there.

Managers with fewer reports are also working fine, so I feel like this is an issue with a maximum length limitation on the list collector field (30 users is around the 1000 character mark). Just wondering where to go to increase the maximum size, if it's possible.

Any help would be appreciated.

1 ACCEPTED SOLUTION

david_williams1
Kilo Expert

Hey Everyone,

I managed to figure this out. This thread was helpful

The issue appears to be some kind of limitation in using setValue on a service portal list collector, if you are assigning more than 30 values it doesn't generate the display value automatically and the code fails. The solution is to explicitly set the display value to another comma separated list of names which needs to be generated at the same time as getting the list of sysids.

When explicitly setting the display value list using setValue(field, value, displayvalue) with value being the comma separated list of sysids and displayvalue being the comma separated list of names, everything works as intended.

My final working server code is below, hopefully it will help someone in the future.

(function() {
	if (input && input.action) {
		var action = input.action;
 
			if (action == 'direct') {
				gr = new GlideRecord('sys_user');
				gr.addQuery('manager',gs.getUserID());
				gr.addActiveQuery();
				gr.query();
				var users = [];
				var usernames = [];
				while (gr.next()){
					users.push(gr.getValue('sys_id'));
					usernames.push(gr.getDisplayValue('name'));
				}
				data.field = options.field;
				var people = "";
				var names = "";
				for (var i=0;i<users.length; i++){
					people += users[i];
					people += ",";
					names += usernames[i];
					names += ",";
				}
				data.people = people;
				data.names = names;
			}
			if (action == 'all') {
				var results = getReportsRecursive(gs.getUserID());
				var allReports = results[0];
				var allnames = results[1];
				var people2 = "";
				var names2 = "";
				for (var j=0;j<allReports.length; j++){
					people2 += allReports[j];
					people2 += ",";
					names2 += allnames[j];
					names2 += ",";
				}
				data.field = options.field;
				data.people = people2;
				data.names = names2;
			}
	}
	
	function getReportsRecursive(user){
		gr = new GlideRecord('sys_user');
		gr.addQuery('manager',user);
		gr.addActiveQuery();
		gr.query();
		var users = [];
		var names = [];
		var count = gr.getRowCount();
		while (gr.next()){
			users.push(gr.getValue('sys_id'));
			names.push(gr.getDisplayValue('name'));
		}
		for (var i=0; i<count; i++){
			var results = getReportsRecursive(users[i]);
			var reports = results[0];
			var reportnames = results[1];
			for (var j=0; j<reports.length; j++){
				users.push(reports[j]);
				names.push(reportnames[j]);
			}
		}
		return [users,names];
	}
 
})();

View solution in original post

16 REPLIES 16

sachin_namjoshi
Kilo Patron
Kilo Patron

Please check below to increase size of list collector variable

 

https://www.servicenowguru.com/scripting/client-scripts-scripting/change-size-list-collector-slushbucket-variable/

 

Regards,

Sachin

Thanks, sachin, but I'm looking to increase the size limitation in the database, not the physical size on the page.

you need to update number in glide.xmlhttp.excessive system property.

Please check below for more details.

 

https://hi.service-now.com/kb_view.do?sysparm_article=KB0523809

 

Regards,

Sachin

SatheeshKumar
Kilo Sage

Hi,

 

i dont think it was limit issue.

 

i too found similar issue reg list collector in sp.check your data if it has ',' in dispay value. not sure this is reason for issue but check this too.

 

If your data ',' in its name there will be some issue in setting values to list collector. 

 

soln:

used different delimiter other than ',' to make  no of sysid equals to no of display value.

 

Thanks,

satheesh

Thanks, satheesh. I'm just setting the value to a comma separated list of user sysids. I took a look through the list manually to make sure and there aren't any excess commas in the sysids.

Thanks for the suggestion though.