Remove option from list collector based on selection in same list collector

sahusanjeep95
Giga Expert

I have 3 choices created in list collector.

Choice 1 

Choice 2 

Choice 3 

My requirement is once choice 1 is added then hide choice 2 and choice 3 to be selected. If choice 2 or choice 3 is selected then hide choice 1 to be selected.

I tried through onchange  client script to hide option with removeOption method but its not working.

 

Could you please help me with it?

 

Thanks

Sanjeep

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

The removeOption method only works for Select Box type variables.  What you need to do is update the filter on the List Collector, so your onChange Catalog Client Script would look more like this:

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	var parm = '';
	if (window === null)
		parm = 'portal';
	else
		parm = 'native';

	var varName = 'select_appli_list';// name of the list collector variable
	var filterString = '';
	if (newValue.indexOf('choice 1') != -1) { //choice 1 is one of the selections
		filterString = 'sys_idINchoice 1'; //new list filter will only contain 1 choice
	}
	if (newValue.indexOf('choice 2') != -1 || newValue.indexOf('choice 3') != -1) {
		filterString = 'sys_idINchoice2, choice3';
	}
	
	//reset the filter (left side) based on the selection(s)
	if(parm == 'portal'){
		var myListCollector = g_list.get(varName);
		myListCollector.reset();
		myListCollector.setQuery(filterString);
	} else {
		window[varName + 'g_filter'].reset();
		window[varName + 'g_filter'].setQuery(filterString);
		window[varName + 'acRequest'](null);
	}
}

Replacing 'choice 1' etc with the sys_id of the record.