- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 07:36 AM
Hi All,
I am trying to remove a specific choice value from a variable.
The variable is used by multiple catalog items. So, we added a client script on a specific item to hide it.
But, the script is not hiding the choice value.
g_form.removeOption("loaner_selection",'visitor');
Kindly provide a quick solution to solve it 🙂
Thanks,
K. Francis Xavier
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 08:03 AM
This worked for me ::
Since each choice is unique you can hide them by using the document.getElementById in a onLoad catalog clients script. Just use your web inspector to find the right ID.
//Check the attachment to know how to get the IO ID.
https://community.servicenow.com/5bab600edbd09344e9737a9e0f961915.iix
var choice = document.getElementById("IO:2db72215876d11008eb5098e59434d8c_5c296215876d11008eb5098e59434df5").parentNode.parentNode;
if (choice){
choice.style.visibility="hidden";
choice.style.display="none";
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 07:46 AM
Hi,
A quick solution is always nice, heh.
You can definitely get a quick solution if you speak to your peers at Accenture, since you're with a large partner firm...so a simple ping on your teams or slack social app I'm sure would get you help pretty quickly...
As far as removing an option from the variable, this will only work on a select-box type variable (not multiple choice). Please verify that you have the field name correct, as well as the value.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 07:58 AM
Thank you 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 08:03 AM
This worked for me ::
Since each choice is unique you can hide them by using the document.getElementById in a onLoad catalog clients script. Just use your web inspector to find the right ID.
//Check the attachment to know how to get the IO ID.
https://community.servicenow.com/5bab600edbd09344e9737a9e0f961915.iix
var choice = document.getElementById("IO:2db72215876d11008eb5098e59434d8c_5c296215876d11008eb5098e59434df5").parentNode.parentNode;
if (choice){
choice.style.visibility="hidden";
choice.style.display="none";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 10:43 AM
Although the above advice will work, it's not great practice. Try this better approach.
The reason you are seeing the issue is that g_form.removeOption does not work through Client Scripts that try to access a variable field on a task record. g_form is not a supported API for variables on Task Records.
The way to get this working is using: g_sc_form.removeOption
e.g.
g_sc_form.removeOption('your_variable', 'your_value');
You can check the official advice on this at:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0678206
Regards
Paul