- 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
06-10-2016 07:06 AM
Once your catalog item is loaded, can you run the same script to remove option on Javascript executor (ctrl+shift_alt+j) and share the result?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2016 07:28 AM
Hum, nothing happen when I paste => g_form.removeOption('myVariablename', 'OneValueOfmyQuestionChoices');
in the window...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2016 07:29 AM
now the only scope of error is that you are passing wrong arguments in removeOption function . I would cross check that and then double check it again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2016 07:43 AM
I opened the javascript executor inserted the code and clicked "Run my code" but nothing seems to happen. Tried in both Waterfox and Chrome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2016 07:36 AM
I've had this problem in both Fuji and Helsinki.