How to Hide variable dropdown choice from the Catalog item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 11:27 PM
We have two identical catalog item in a service portal. We have to Hide one of dropdown choice from one single catalog item, we use below client script but it didn't work. Please provide some relevant solution for hiding the choice. Please find the below client script we have used.
For onChange
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
g_form.removeOption('variable name', 'option');
}
For onLoad
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.removeOption('variable name', 'option');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 12:27 AM - edited 01-19-2023 12:29 AM
Hi @Tanmay Karankar ,
What exactly the type of variable is it select box ?. If not then change the type of variable to select box and then. try.
if still not working then try
g_sc_form.removeOption('test_var', 'choice_one');
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 04:33 AM
Hi @Gunjan Kiratkar ,
Thank you for replying. But It Still not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 04:55 AM
Hi @Tanmay Karankar ,
The script for onload which you have provided is working on my side. Please try below code as well
function onLoad() {
//Type appropriate comment here, and begin script below
//g_form.removeOption('select_month', 'mar');
if(g_form && g_form.getControl('select_month')) { //replace with your variable backend name
g_form.removeOption('select_month', 'mar'); ////replace with your variable backend name & Choice value
}
}
Example:-