ServiceNow - Dependent Variables on Record Producer in Service Catalog

Author by Scott Poling

For those of you working with record producers and building out dynamic pages, you may be aware that this can be a bear to work with. I have done this in the past and always need reference material.You may be reading this and wondering what the use case for this guide is. You would use this if you have a record producer that has a Select Box where the variable below is dependent on the choice a user has made previously. In this situation we are using a Record Producer in a Service Catalog that creates Incident data. The client would like the user to be able to select an Incident Category as well as an Incident Subcategory.

 

You will need a variable of Category and a variable of Subcategory.

Here is the Category Variable configuration:

 

1.png

 

2.png

 

Here is the Subcategory Variable configuration:

3.png

 

Make sure this one is a Lookup Select Box. The reference qualifier here is important. You need the element to match the element you created in sys_choice

Reference Qualifier: javascript:'name=incident^element=subcategory^dependent_value=' + current.variables.category


Now this is how these two look in the portal:

4.png

 

Let’s navigate to the sys_choice table. You can do that by going to sys_choice.LIST in the application picker.

 

5.png

 

Now that we are here, let’s sort by the Incident table.

6.png

 

I have populated some categories in addition to the out of box categories included with Madrid. Populate as many categories as you would like in here. Please keep in mind that simple is generally best with ServiceNow. Letting users select categories may be specific to the scope of the clients work. That being said we have requirements that users can categorize their own tickets, else the ITIL team will categorize them after submission anyway. After we made some base categories lets make some matching subcategories. The element HAS to match in your reference qualifier for the subcategory variable.

7.png

 

Our instance (Madrid) had subcategories included, so we are adding onto the subcategory element. Let’s create a new one.

8.png

9.png

 

Here we created a new choice with the following

 

Table > Incident

Element > subcategory

Language > en

Label > DevOps

Value > devops

Dependent value > software

 

Labels are the pretty version of the data that drives behind it. I generally will use all lowercase with underscores if I need to include spaces in values. The dependent value is the value that this data depends on. Which means if you select a Category of Software, all Subcategories with dependent values of Software will show. Once you have this entered click Submit. Only do this for a few Categories for the time being. We want to test that our qualifier works.

 

Alright now this should be functioning. Let’s try it out!

 

14.png

 

When the Category changes, the Sub Categories are populated as they should.

Thank you for taking the time to read this, I hope this can be useful in the future. Even the most proficient developers need reference material from time to time.

 

Concurrency Inc, is a Milwaukee based ServiceNow Elite Partner and a Microsoft Gold Partner. Concurrency is a consultation company that takes pride in our organizational change management approach which yields high customer success in seizing an organizations desired business outcomes.  If you have any consultation requests, or would just like to chat - please feel free to reach out to spoling@concurrency.com