How to hide question choices on a service catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2019 11:53 PM
I have a service catalog item containing 4 question choices.
I need 2 of these question choices hidden based on current user's logged in role.
The crucial thing is I am unable to check out how to hide thse fields even without the dependancy on a user's role.
I tried this:
g_form.removeOption('value','cym3');
g_form.removeOption('value','cym6');
'value' is question choice's value. I tried this in Catalog client script however it does not work.
I use Madrid instance.
Can anyone please help?
Thanks a lot!
Milan
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2019 12:13 AM
checking

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2019 12:23 AM
i checked you have used multiple choice type variable on catalog form. then in that case removeOption() will not work. if you still want to hide them then you have to use DOM which is not a good practice and not a best approch to hide those option. i would suggest change the field type to Select Box.
either you convert the variable type as Select box , so you can create a dropdown option and then removeOption() will work.
you can see if you want to hide the multiple choice type of variable choices then you have to use DOM manipulation which is not a good approach.
function onLoad() {
alert('hey you !');
// g_form.removeOption('pack_type','cym3');
// g_form.removeOption('pack_type','cym6');
//Type appropriate comment here, and begin script below
var choice = document.getElementById("IO:0cf9e219db85330042bfe9c94896198a_0e3ae619db85330042bfe9c948961904").parentNode.parentNode; // Use the entire id so that you can hide particular choice.
if (choice){
choice.style.visibility="hidden";
choice.style.display="none";
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2019 12:45 AM
Changed it to select Box and it works! 🙂
Appreciate your help and thank you for the additional piece of code as well...
Milan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2019 12:47 AM
glad i helped. kindly mark my answer as correct and close this thread.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 09:25 PM
Hi,
Get Controls can hide option, it works for me.
Step1. Get Controls to get multiple NodeList
Step2. Dowalk to upper parent node and hide
g_form.getControls('multiple_choices').forEach(function(e) {
if (e.value == 'yes')
e.parentElement.style.display = 'none';
});
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Cuong Phan
DXC Consultant.
Cuong Phan
ServiceNow Technical Lead