modifying sys_class_name choices

Dubz
Mega Sage

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?

find_real_file.png

1 ACCEPTED SOLUTION

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.


View solution in original post

5 REPLIES 5

Justin Abbott
Giga Guru

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.


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.


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.


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!