Depending on another variable value, remove / add options in list collector
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 09:31 AM
On a catalog item, I have two variables:
Location
Accessories
If the Location is TEST, then I need to hide two of the accessory options from the list collector view. Below I have an OnChange Client Script, but it does not appear to be removing or adding options. They all show in all scenarios.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// if location is FLC, remove wireless keyboard and wireless mouse from options
if (g_form.getValue('location') == 'cee089228779c91009d831583cbb35ba') { // TEST Sys ID
//these items are in a list collector
g_form.removeOption('special_accessories', 'Wireless keyboard' ,'Wireless keyboard');
g_form.removeOption('special_accessories', 'Wireless mouse', 'Wireless mouse');
g_form.addOption('special_accessories', 'Headset', 'Headset');
g_form.addOption('special_accessories', 'Second monitor','Second monitor');
} else {
g_form.addOption('special_accessories', 'Wireless keyboard' , 'Wireless keyboard');
g_form.addOption('special_accessories', 'Wireless mouse', 'Wireless mouse');
g_form.addOption('special_accessories', 'Headset', 'Headset');
g_form.addOption('special_accessories', 'Second monitor', 'Second monitor');
}
}
Any ideas?
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 12:13 PM
how are you adding those values on form load.
and what is the result of the below line of code, add alert method for run time value check
g_form.getValue('location')
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution