removing selected value from list collector

Amit Dey1
Tera Contributor

hi ,

I have 4 values in a list collector variable - c-a , c-b , c-c , c-d . Let's say we can select c-b , c-c ,c-d but when we select c-a after selecting any of these value then c-a will be removed and if we select c-a at first then if we select any other value from the list  that other value  wll be removed , how can we achieve this

2 REPLIES 2

Community Alums
Not applicable

Hi @Amit Dey1 ,

 You can use this sample script :

var myListCollector = g_list.get(collectorName);

var selectedOptions = g_form.getValue(collectorName).split(',');

if((selectedOptions != "") && (selectedOptions.length > 0))

{

         //Remove items

      //    var index = 0;

      //    for (var i = 1, leng = selectedOptions.length+1; i < leng; i++){

          myListCollector.removeItem(selectedOptions[selectedOptions.length-1]);

       //   index++;

      //    }

}

Ankur Bawiskar
Tera Patron
Tera Patron

@Amit Dey1 

can you explain your complete business requirement?

user can select any value in any order in list collector

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