- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2016 04:22 PM
I am trying to remove an option from a select box on a catalog variable but it does not remove. The script is:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
g_form.removeOption('eai_reviewer_sel_next_task', 'eai_research');
//g_form.clearOptions('eai_reviewer_sel_next_task');
//g_form.addOption('eai_reviewer_sel_next_task', 'uat_implement', 'UAT Implementation');
//g_form.addOption('eai_reviewer_sel_next_task', 'prod_implement', 'PROD Implementation');
}
The g_form.clearOptions and g_form.addOption functions seem to work fine but the g_form.removeOption does not. I would prefer to not clear all options and add back the ones I need as I need to include the 'none' option and its setMandatory properties.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 01:17 PM
In case you are still having this problem or someone else stumbles upon this, I was having a similar problem with getControl(), clearOptions() and removeOption() not running on Catalog Tasks or Requested Items when I found this article.
ServiceNow KB: The g_form.getControl method does not work after ordering (KB0547171)
I added the suggested code below to my client scripts and used form.removeOption instead of g_form.removeOption.
var form = typeof g_sc_form != "undefined" ? g_sc_form : g_form;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2017 06:23 AM
Hi All,
I have quite the same problem, but in the Record Producer
I have defined a variable named "operating_system" [it is a multiple choice variable], that contain 5 possible values.
Now, from the Catalog UI Policy I have defined one rule that are triggered the following code:
function onCondition() {
// g_form.removeOption('operating_system', 'linux');
// g_form.removeOption('operating_system', 'android');
// g_form.removeOption('operating_system', 'ios');
var form = typeof g_sc_form != "undefined" ? g_sc_form : g_form;
form.removeOption('operating_system', 'linux');
form.removeOption('operating_system', 'android');
form.removeOption('operating_system', 'ios');
}
but this dont't work and I can't undestand why ... I have also modify the g_form variable with the variable "form", defined like indicated in the previsu post.
Can someone identify why this don't work?
Regards
Vincenzo

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 01:52 PM
hi it's not working
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var form = typeof g_sc_form != "undefined" ? g_sc_form : g_form;
form.removeOption('additional_systems','24');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 10:56 AM
Nothing worked..
g_form.removeOption("cer_type_of_headset", "Duo");
or
var form = typeof g_sc_form != "undefined" ? g_sc_form : g_form;
form.removeOption("cer_type_of_headset", "Duo");
or
g_sc_form.removeOption("cer_type_of_headset", "Duo");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2020 11:36 AM
Has anyone been able to get the g_form.remove.Option method to work on Catalog items yet?
I was told this was due to an "order of execution" error in Orlando Patch 1 and earlier.
SNOW said this was supposed to be addressed in Orlando Patch 2.
We are now on Orlando Patch 4 and I still can't get this to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2020 08:05 AM
It works but you need to use the full set of parameters:
g_form.addOption('priority', '6', '6 - Really Low');
g_form.removeOption('priority', '6', '6 - Really Low');
If you just use the value, it does not work.
Jack