- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2017 03:30 AM
On our Problem form users can add a new CI if the one they need is not already there. On the form there is an option to select the Class, this is a choice list of type 'System Class Name'. I want to restrict the classes available in this choice list, can anyone advise on how to achieve this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 05:45 AM
g_form.clearOptions() clears all options. You could clear all, then add back only the preferred classes. GlideForm (g form) - ServiceNow Wiki.
Example:
g_form.clearOptions('sys_class_name');
g_form.addOption('sys_class_name', 'cmdb_ci_server', 'Server');
Or, rather than using this client-side code, you could create a custom UI Page that facilitates adding a new CI. You could add your filter in a <g:ui_reference> tag. Extensions to Jelly Syntax - ServiceNow Wiki.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2017 01:38 PM
If it's a choice list on a form, you could look at the g_form.removeOption() method here: GlideForm (g form) - ServiceNow Wiki.
Or maybe build out a reference qualifier, if one would apply: Reference qualifiers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 02:01 AM
The list currently has 572 choices on it (the 11 listed in the screenshot above are what remain after i tinkered with it on my dev instance), I need an easier solution that individually removing 560 choices from that list!
A dictionary override with a reference qualifier doesn't work, nor does modifying the the choice list on the advanced view.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 05:45 AM
g_form.clearOptions() clears all options. You could clear all, then add back only the preferred classes. GlideForm (g form) - ServiceNow Wiki.
Example:
g_form.clearOptions('sys_class_name');
g_form.addOption('sys_class_name', 'cmdb_ci_server', 'Server');
Or, rather than using this client-side code, you could create a custom UI Page that facilitates adding a new CI. You could add your filter in a <g:ui_reference> tag. Extensions to Jelly Syntax - ServiceNow Wiki.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 02:48 AM
Hi Justin,
I just got round to testing with g_form.clearOptions and it works perfectly. It's a bit of a pain having to individually add back in the classes that i want but it's less of a pain than trawling our CMDB and cleaning up the erroneous records my guys create!
Jelly is way beyond my skillset so i'll stick with clear/add for now!