how to remove values from list collector field .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2023 07:08 AM
I have created one record producer in which i created one list collector field on the portal in which 8 different values gets visible.
On the bases of selected values in field A and field B the values should be hidden on the list collector field.please suggest how to achive this. I tried using ui policy and withing that method "removeOption" but its not working as it should be working for choice type field not for list collector

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2023 09:30 AM
Just to give you an idea, here is a sample client script which removes Item from the list collector in a client script.
function onChange(control, oldValue, newValue, isLoading) {
//Limit the number of selected options in a list collector
//Specify the max options and variable name below
var maxOptions = 5;
var collectorName = 'users';
var myListCollector = g_list.get(collectorName);
var selectedOptions = g_form.getValue(collectorName).split(',');
if(selectedOptions.length > maxOptions){
//Remove the last item
myListCollector.removeItem(selectedOptions[selectedOptions.length-1]);
g_form.addErrorMessage('You cannot select more than ' + maxOptions + ' options.');
}
}
Instead of "removeOptions" you need to use removeItem method to remove items from the list collector variable.
Source: https://servicenowguru.com/scripting/client-scripts-scripting/limiting-selections-list-collector/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2024 11:21 AM
To remove certain options when another variable choice is selected in Record Producer, follow these steps:
1. Go to Subcategory variable, and under Type Specification tab use "Reference qual" field
2. Write query:
javascript: new script_include_name().method_name(current.variables.subcategory + "");​
3. Create script include and method to be called from Reference qual, and check if subcategory is "lease" then return query that will remove "other" from list collector. (If you are facing difficulty in writing query, I can help you there)
4. Click on Save button to save the changes on variable and script include.
Attaching example of reference qual.
Thanks,
Shivanshu