Skip to Main Content

The other day while working on the blog article The Ultimate Field Type Guide I was exploring configuration options for the Conditions field type. While browsing through ServiceNow's out of the box usages of this field type I saw something named "Related List Conditions". A filter mechanism for related tables which is only available when setting the dictionary attribute: allow_related_list_query=true.

Related List Conditions
Related List Conditions of the "Conditions" Field Type

I started to play around with this control, saved the form and checked the actual value stored in the database. The result was an encoded query string, different to what I have actually ever encountered before in ServiceNow. It looked like this:




After figuring this out I wanted to know if this kind of queries can also be used when building regular GlideRecords, so I started to investigate a bit further. I have tried several scenarios and here is how it works. The general syntax is:


Here is a real live example:

var incidents = new GlideRecord('incident');

This query translates to:

Give me all incidents which have at least 1 referencing breached Task SLA.



If you want to further filter the incidents of our example you can either do this through the regular  addQuery() method or by attaching the encoded query before or after the related query:

// Attaching the encoded query BEFORE

// Attaching the encoded query AFTER

Both of the above queries are equivalent and translate to:

Give me all incidents whose short descriptions contain "example" and which have at least 1 referencing breached Task SLA.



When it comes to the   <quantifier>  part of the syntax mentioned above, there are several options available:

// More than 1

// Equals or more than 1

// Less than 1

// Equals or less than 1

// Exactly 1

// Not 1

// Between 1 and 3