Hide Choice option of multiple choice variable in service catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2021 11:30 PM
Hi,
I have to hide choice option from multiple choice variable in catalog item
but my code is not working,here is my code :
function onLoad() {
g_form.removeOption('Select Type of request','disable_account');
}
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2021 11:33 PM
g_form.removeOption('Select Type of request','disable_account');
is "Select Type of request" the backend name of your variable, if not please use the backend name.
Please mark this correct/helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2021 11:42 PM
Hi Raghav,
I used backend name though but its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2021 11:53 PM
The code is correct if you are using backend name for both variable and choice:
g_form.removeOption(<fieldName>, <choiceValue>);
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2021 11:54 PM
g_form.addOption() and g_form.removeOption() won't work on Multiple Choice variable
it only works for Select box with choices
you will have to use DOM manipulation for this which is not recommended.
For native this should work
g_form.getControls('variableName').forEach(function(e) {
if (e.value == 'disable_account')
e.parentElement.style.display = 'none';
});
for portal you will have to use something using class
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader