One common requirement JDS sees when working with ServiceNow customers is the need to dynamically filter the available choices in reference fields. This can be useful in both general form development and record producers.

Consider the following business requirement:
A national charity wants to implement a feedback form for its staff.
As staff work across a variety of areas, it’s important to match staff with the correct department, so the correct department manager can be notified about the feedback.

The charity has provided us with some sample data for testing:

Departments

Filtered Reference Fields in ServiceNow 1

Department Staff

Filtered Reference Fields in ServiceNow 2

As this feedback form is available to anyone working within the charity, JDS has built a record producer to capture feedback using the Service Catalog within ServiceNow.

Filtered Reference Fields in ServiceNow 3

To limit the available choices to only staff within a particular department, we’ll need to use a script that is triggered whenever anyone starts typing in the field or accesses a value lookup for the variable “Who would you recommend?”
Although there are numerous ways to approach this, always look for the simplest option. Rather than calling a custom script, use the Reference qualifier field in ServiceNow to set up the relationship.

Filtered Reference Fields in ServiceNow 4

Normally, fields on a form can be referenced using current.fieldname but record producers within a service catalog are slightly different, and need a slightly more qualified reference of current.variables.fieldname.

Let’s look at the results…

If we select “Community Outreach” the list of staff available under “Who would you recommend?” is limited to Jane Brown and Sarah Smith.

Filtered Reference Fields in ServiceNow 5

If we select “Youth Action” the list of staff available under “Who would you recommend?” is limited to Matthew Jones and Sarah Smith.

Filtered Reference Fields in ServiceNow 6

ServiceNow is a powerful platform that allows for advanced customisations to ensure a good fit with business requirements.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.