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

I'm happy to help. Thank you for the kind words. I hope we have a chance to meet in person some day soon.


I have a follow up question:


What if I want to filter the result to have just 'active' records?



The reference qualifier takes all CIs that have a sys_class_name=current.category; including those marked as inactive. I would like to exclude those.


How do I proceed?


ctomasi


Hi,



Yes, you can 'add on' to the reference qualifier. The "and" part of that would look like this:



javascript:'sys_class_name=' + current.category + '^active=true'



Of course, 'active=true' is dependent on your field names. For example you may be using installed_status=in_production for example. Adjust accordingly.



The end result of advanced reference qualifiers is they have to be a valid encoded query string.


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


mbayefdieng
Giga Contributor

Hi ctomasi



I unfortunately noticed that using the CI table as value to the category list options is not accepted by ServiceNow system.


Those list options are not accepted and stored. Everytime I make the change and disconnect, to come back, those choice lists with values equal table names   are removed from the category field.



Is there another way to achieve this?