Sangeetha6
Tera Expert

I had a question, on how to populate restrict values in List Collector field based on the change of another field.
I checked many community but we had a similar question/ blog which shows how this can be achieved in Catalog form not in Table form view. So I tried different ways and found the easiest way.

Let us consider there is a requirement to restrict/ display only the members in "Assigned to" list field based on the selected "Assignment group" value in reference field.

Field 1: Assignment Group (Reference field - sys_user_group table)

Field 2: Assigned to (List Collector - sys_user table)

Create a Script Include:

Name: getMembers

Script:


function getMembers(grp){
	var applicationList = '';
	var len = [];
	var grp_mem = new GlideRecord('sys_user_grmember');
	grp_mem.addQuery('group', grp);
	grp_mem.query();
	while(grp_mem.next()){
		if(len.length > 0){
		applicationList+= (','+grp_mem.user.sys_id)+'';
		len.push(','+grp_mem.user.sys_id);
	} else {
		applicationList = grp_mem.user.sys_id+'';
		len.push(grp_mem.user.sys_id+'');
	}
	}
	return 'sys_idIN' + applicationList;
}

In the List Collector field - "Assigned to" - you have to update the Reference Qualifier (advanced) as 
javascript: getMembers(current.assignment_group);

So that based on the selected "Assignment group" - "Assigned to" list will be restricted when clicking on reference icon in the list collector field.

Also make sure - the list collector field is referenced to some table - so that we can try this option with choice list we can not achieve this.

Based on your requirement you can change the above script accordingly.

I hope this helps.

Version history
Last update:
‎06-16-2022 11:19 PM
Updated by: