- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 02:46 PM
Hello ,
I need assistance with a catalog client script . It is partially working. I want to hide "Training Only" variable value from the Make Selection select box if Oracle is selected from the Select Subject Matter select box. When I select Oracle, it hides "Training Only" but it also hides it when I select any of the other select box variable value choices.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 04:46 PM
Hi @Rhonda9 ,
The issue you're experiencing is due to the fact that once the option is removed, it's not being added back properly for other selections.
Additionally, the addOption method in your code lacks the required parameters (choice value and choice label).
Here is the updated code please try-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'Oracle') {
g_form.removeOption('training_type_of_training_services', 'Training Only');
} else {
// Ensure 'Training Only' option is added back if not already present
if (!isOptionPresent('training_type_of_training_services', 'Training Only')) {
g_form.addOption('training_type_of_training_services', 'Training Only', 'Training Only');
}
}
}
// function to check if an option is already present in the select box
function isOptionPresent(variableName, optionValue) {
var options = g_form.getOption(variableName);
for (var i = 0; i < options.length; i++) {
if (options[i].value == optionValue) {
return true;
}
}
return false;
}
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 04:44 PM - edited 07-16-2024 04:45 PM
Hey Rhonda,
The best way to handle such requirements is to place the clearOptions() at the top... let it execute first and wipe all the options. And then, conditionally add your desired options using addOption()
removeOption() always causes too much heartache 😉

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 04:46 PM
Hi @Rhonda9 ,
The issue you're experiencing is due to the fact that once the option is removed, it's not being added back properly for other selections.
Additionally, the addOption method in your code lacks the required parameters (choice value and choice label).
Here is the updated code please try-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'Oracle') {
g_form.removeOption('training_type_of_training_services', 'Training Only');
} else {
// Ensure 'Training Only' option is added back if not already present
if (!isOptionPresent('training_type_of_training_services', 'Training Only')) {
g_form.addOption('training_type_of_training_services', 'Training Only', 'Training Only');
}
}
}
// function to check if an option is already present in the select box
function isOptionPresent(variableName, optionValue) {
var options = g_form.getOption(variableName);
for (var i = 0; i < options.length; i++) {
if (options[i].value == optionValue) {
return true;
}
}
return false;
}
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 06:24 AM
Thank you , this works !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 04:51 PM
Hi,
"select box" usually captures sys_id value, could you try the following instead
//Correct code
if(newValue == "<sys_id_of_oracler_record")
// instead of below - incorrect code
//if(newValue == "Oracle")
Hope this helps.
Thanks,
Dhruv