Insights ServiceNow – Dependent Variables on Record Producer in Service Catalog

ServiceNow – Dependent Variables on Record Producer in Service Catalog

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:

Here is the Subcategory Variable configuration:

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:

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

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.

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

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!