- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello I am trying to hide a value from a select box on a catalog item based on a value selected in another field.
The "Backup Job Failure" value in the Action field should only show when "Hosting Location" is ANG Non-Co-located
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
you can use onChange catalog client script on that Hosting location variable, check value and remove the option
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// give correct choice value to compare here
if (newValue == 'ANG Non-Co-located')
g_form.removeOption('actionVariable', 'backup_job_failure'); // give correct variable name and correct choice value here
else
g_form.addOption('actionVariable', 'backup_job_failure', 'Backup Job Failure'); // give correct variable name and correct choice value here
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
you can use onChange catalog client script on that Hosting location variable, check value and remove the option
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// give correct choice value to compare here
if (newValue == 'ANG Non-Co-located')
g_form.removeOption('actionVariable', 'backup_job_failure'); // give correct variable name and correct choice value here
else
g_form.addOption('actionVariable', 'backup_job_failure', 'Backup Job Failure'); // give correct variable name and correct choice value here
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @DreDay3000
if you are populate select box variable (var1)choices based on other variable (var2) value selection , then create onchange client script on that variable (var2).
var var1 = g_form.getValue("var1");if(newValue=="catalog_value")
{
g_form.removeOption('var1','option to be cleared');
}
else{
g_form.addOption('var1','add that option again here');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
FYI: addOption() requires 3rd parameter as well which is choice label.
Please check docs
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
To hide a specific choice in a Select Box variable based on another variable’s value, use an onChange Catalog Client Script in ServiceNow.
Since you only want to control one option in the Action field, use g_form.removeOption() and g_form.addOption().
Create the client script on the variable and conditionally remove or add the required choice in the Action field based on the selected value.
If this resolves your issue, please mark the response as correct.

