Current in Advanced Reference Qualifiers

General Add comments

The “Current” object in the context of Reference Qualifiers is an interesting object that can assist in delivering the filter you are looking for in a Reference Qualifier. This article describes how to work with this object.

Reference Qualifiers

A Reference Qualifier is used to restrict the amount of records that are returned when a user tries to select a record in a Reference field.
Out of the box there are three types of Reference Qualifiers:

Simple Reference Qualifier

This Reference Qualifier is a basic filter that can be configured just as you would create a filter for any list in ServiceNow.
This means that the Simple Reference Qualifier is not able to make use of the context of the record and only has limited access to the data in the record.

Dynamic Reference Qualifier

For this article I have been playing around with Dynamic Reference qualifiers (in a Kingston release). I ran into some odd behaviour:
When updating the Dynamic Filter Option that is linked to a Reference field, the Reference field changes from being a “Dynamic” reference to an “Advanced” reference, and the old value of the Dynamic Filter is copies to the Reference Qualifier field of the Dictionary record
The Script field in the Dynamic Reference Qualifier expects current.addQuery(…, …); and current.addEncodedQuery(…) doesn´t seem to work.

Because of this, I will not go too much deeper into the dynamic reference qualifiers. I would actually suggest to ignore them for know. The concept is strong, but the execution a bit poor.
Advanced Reference Qualifier
So now let´s have a look at the options we have in the Advanced Reference Qualifiers.
An Advanced Reference Qualifier always results in an Encoded Query being created. This can be done in 2 ways:
1 Write it directly in a string (in some case ServiceNow automatically translates that to a
2 Write a script that generates the string
Where rqCompany is a Script Include with the following content:

function rqCompany(){
return 'city=Irvine';


People that have been playing with these Advanced Reference Qualifiers may have noticed that they have access to an object named “current”.
Many of you may have assumed that this is the same current that is available to people in a Business Rule, but this is not completely the case.
Investigating the current object will yield the following results:
– All field that are part of the table that you are looking at are available in the object
– Fields that are on the form (either visible or invisible) are in the object, and their value is the value on the form. Even if the record is not saved yet, and even for empty records.
– Fields that are not on the form (visible nor invisible) are also in the object. Their value is the current value in the database. If the record is new, still the initialization values are populated.

The result of this is that the Reference Qualifier adjusts perfectly to the data that is updated by the user.
It is also interesting to mention that dotwalking is possible, even for reference fields that were updated on the form only, and even for reference fields in new records.


Leave a Reply