Remove selected value from list collector based on selected value in current list collector

Edwin Fuller
Tera Guru

I have a list collector that should only allow either "Dual Monitor" or "Single Monitor" to be selected, but never both. This list collector has other values that can be selected that should not be removed when removing "Dual Monitor" or "Single Monitor". 

 

Example:

I add Dual Monitor to list collector and then add Single Monitor to list collector. Script should remove Dual Monitor and keep Single Monitor.

 

OR

 

I add Single Monitor to list collector and then add Dual Monitor to list collector. Script should remove Single Monitor and keep Dual Monitor.

 

In both examples, if other values are part of the list collector then they should remain

EdwinFuller_0-1681878060685.png

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Edwin Fuller 

so both the values cannot be selected. either one should be present

you can use onChange catalog client script on that variable

If both are present then what should be done? which one to be removed?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

 

Which ever value is selected first should be removed. Meaning, if I add "Dual Monitor" first and then add "Single Monitor" afterwards. "Dual Monitor" should be removed since it was added first.

@Edwin Fuller 

then what script did you start with and where are you stuck?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Edwin Fuller 

if you manipulate and remove the value and again set the variable

the onChange client script will run again

So it will go in loop again since you are setting the value using g_form.setValue()

what will happen if the user doesn't select either -> this is fine ?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader