removing selected value from list collector
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 08:33 PM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 09:57 PM
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++;
// }
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 10:21 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader