Remove just single value from selected values in a list collector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 06:58 AM
Initially a user selects multiple values in a list collector. In this list collector users select devices and we have a functionality already developed where in if a device has already been submitted then we should not allow the user to select that device.
Now the requirement here is just that, we should clearvalue of that last selected device and not clear the entire contents of the list collector. For ex. If 2 values are selected then only the recently selected value(for which already request has been submiited) should be cleared.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 07:08 AM
Hi,
I don't think you'll be able to address this by removing the "last selected" entry to the list collector, but instead...you'll need to address it at the actual selection itself. Meaning, you would need to identify the sys_id of the selection that needs to be removed and then remove just that one selection. So however you're determining that the device has already been submitted, maybe through glideajax/SI? then you'd use that same sys_id and remove that from the selection of values in the list collector.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2019 03:03 PM
Hello,
Just wanted to check-in on this and see how things are going.
Let me know if you need any further assistance.
Please mark any reply as Helpful through this thread, if it was, and the Correct answer as Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 07:13 AM
Hi Nolan,
Refer this Link
Try this below code
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-i]);
index++;
}
}
Please Mark Correct/Helpful answer if it helps you.
Regards,
Kunal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2019 01:14 AM
Thanks for the code.
It works as below:
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++;
// }
}