Change form - How to make the CI field dependent on the change category field?

mbayefdieng
Giga Contributor

Hi everyone,

I am new to ServiceNow development and I am struggling with this.

I am trying to modify the change form so that:

  1. the [category] field lists all active CI classes. the values of this field should come from the CMDB
  2. the [CI] field should be dependent on the [category] field

My question is:

  • Which table stores the CI classes? If, there is none how do I query the list of active CI classes in my CMDB?
  • Can you help with the script to accomplish this?
1 ACCEPTED SOLUTION

HI,



Yes, determining "if it has records" could lead to false positives in a hierarchical table structure. If your choices are limited (say 15 or less) than manually creating the choice list is your best answer. Using the class name (e.g. cmdb_ci_server) as a value is encouraged in this case.



To get the CI field to filter on that class, just add a reference qualifier to the dictionary entry for that field.



For example:



javascript:'sys_class_name=' + current.category;



http://wiki.servicenow.com/index.php?title=Reference_Qualifiers



CAUTION: Look at using a dictionary override for your specific table (e.g. change_request) instead of changing the one on the form that is associated to task (and hence all other task related tables like incident, problem, sc_request, etc.)



http://wiki.servicenow.com/index.php?title=Dictionary_Overrides


View solution in original post

8 REPLIES 8

Chuck Tomasi
Tera Patron

Can you help me understand what you mean by "active" CI classes? I can get you a list of all names of classes that extend from cmdb_ci using the TableUtil script include, and that can be used with a reference qualifier on the CI reference field to filter, but what do you mean by "active?"


My CMDB is not using all tables extending the cmdb_ci table but just a few. So by active I mean CI classes, that have existing records (CIs) in the CMDB.


If a CI class does not have CIs recorded in CMDB I do not want it listed.



What if manually I define the list of CI classes as choice items of the category field, and set their values equal to the CI class (table) name? can I use that in a reference qualifier? If so, how?


HI,



Yes, determining "if it has records" could lead to false positives in a hierarchical table structure. If your choices are limited (say 15 or less) than manually creating the choice list is your best answer. Using the class name (e.g. cmdb_ci_server) as a value is encouraged in this case.



To get the CI field to filter on that class, just add a reference qualifier to the dictionary entry for that field.



For example:



javascript:'sys_class_name=' + current.category;



http://wiki.servicenow.com/index.php?title=Reference_Qualifiers



CAUTION: Look at using a dictionary override for your specific table (e.g. change_request) instead of changing the one on the form that is associated to task (and hence all other task related tables like incident, problem, sc_request, etc.)



http://wiki.servicenow.com/index.php?title=Dictionary_Overrides


Thanks a lot chuck for your help and for pointing me to the dictionary override article (wonderful feature).


By the way I am a fan.