Help on g_form.addoption
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 08:53 AM
Hello
I'm trying to practice g_form.addoption on incident table. When the user select software, it should add the option "serviceNow". Else it should remove the option. I'm getting an error: onChange script error: TypeError: g_form.addoption is not a function function () { [native code] }. Thanks for your help.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue('category') == 'software') {
g_form.addoption('subcategory', 'snow', 'ServiceNow', 3);
} else {
g_form.removeOptions('subcategory', 'snow');
}
//Type appropriate comment here, and begin script below
}
8 REPLIES 8

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 08:55 AM
@huyjor Please try the following script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue('category') == 'software') {
g_form.addOption('subcategory', 'snow', 'ServiceNow', 3);
} else {
g_form.removeOption('subcategory', 'snow');
}
//Type appropriate comment here, and begin script below
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 09:20 AM
The error went away but the option under subcategory is not showing up.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 09:29 AM - edited 12-20-2023 09:33 AM
@huyjor Try this.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue('category') == 'software') {
g_form.addOption('subcategory', 'snow', 'ServiceNow');
} else {
g_form.removeOption('subcategory', 'snow');
}
//Type appropriate comment here, and begin script below
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 09:58 AM
Still not showing 😥