Clear list collector selected values when some field is changed in Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 07:42 AM
How to clear list collector selected values when some field is changed in Service Portal? Say, I have a list collector on cmdb_ci, and I selected some CIs. Now on change of some filed, i want to clear the already selected values from List collector (in Service Portal). Normal Catalog Item works fine as I cannot use 'gel' in Service Portal, also there is no method in g_list to clear existing values. I already tried Refresh(), and it is not clearing existing values.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2017 05:28 AM
Hello - I use g_form.clearValue from a client script to remove all selected values from a list collector, i.e.:
g_form.clearValue('my_variable_name');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2018 12:20 PM
Hi mevenden,
I'm using the g_form.clearValue method to clear the contents of the list collector field on a catalog item in service portal. It is working, however you have to click somewhere for the values to actually be cleared from field.
Did you experience this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2017 03:06 AM
Hi Pritesh
I started looking this article https://www.servicenowguru.com/scripting/client-scripts-scripting/limiting-selections-list-collector...
Then I solved using the code 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-i]);
index++;
}
}
