The CreatorCon Call for Content is officially open! Get started here.

onchange client script for a list collector

RudhraKAM
Tera Guru

I have a requirement on catalog item , on the change of a variable, a list collector will show up and we need to filter the values in the list collector (active=true) , i know we can achieve this  by defining the ref qual condition in the list collector but we have another use case . so can some one please help me with the code ?

 

Thanks in advance 

16 REPLIES 16

try below

function onChange(control, oldValue, newValue, isLoading) {
	//Apply a default filter to the list collector variable
	var collectorName = 'netid_beaker';
	var filterString = 'active=true';

	//Try Service Portal method
	try{
		var myListCollector = g_list.get(collectorName);
		myListCollector.reset();
		myListCollector.setQuery(filterString);
	}
	//Revert to Service Catalog method
	catch(e){
		//Hide the list collector until we've set the filter
		g_form.setDisplay(collectorName, false);
		setCollectorFilter();
	}

	function setCollectorFilter(){
		if(typeof(window[collectorName + 'g_filter']) == 'undefined'){
			setTimeout(setCollectorFilter, 100);
			return;
		}

		//Reset the filter query
		window[collectorName + 'g_filter'].reset();
		window[collectorName + 'g_filter'].setQuery(filterString);
		window[collectorName + 'acRequest'](null);
		//Redisplay the list collector variable
		g_form.setDisplay(collectorName, true);
	}
}

still not working