logo

NJP

Bring back Related List Conditions

Import · Jan 10, 2022 · article

image

There was a time some years ago where ServiceNow offered the version 3 for record lists, but today "List v3 is no longer available for new deployments" (see List v3 administration). I can imagine that there are customer instances which still have activated the version 3. If you don't know which list version you have in your instance, you can read the Comparison of List v2 and List v3.

One cool feature of lists v3 that still lives on, are the so-called "Related List Conditions", which are only available for the Report Builder. At least that's what I thought until I accidentally opened a form for Breakdown Sources and was very surprised to find Related List Conditions there:

image

If Related List Conditions still work outside the Report Builder, there must be some way to utilize that, I thought.

But first, there is an interesting question to be answered.

How exactly can the extended Condition Builder be activated?

The answer to this question is provided by the Dictionary entry of the field "Conditions" for Breakdown Sources:

image

The attributes of interest are

  • condition_builder=v2
  • allow_related_list_query=true

So if this works for Breakdown Sources, does this also apply to other condition fields in the platform, for example Business Rules?

Yes it does! OOTB it is possible to cancel a Problem if it still has open Problem Tasks. To prevent this, the common pro-code approach would be to GlideRecord in a Business Rule the problem_task table in order to check whether there are still active records for the related Problem and if so abort the save/update action. But with the activated Condition Builder v2 (add the mentioned attributes to the field "Filter Conditions"), you can come to the same result without coding and just by configuring a Related List Condition:

image

As a result, the Cancel action is prevented if there are still open Problem Task records:

image

And what is the magic behind the Related List Conditions?

A look at the stored encoded query answers the question:

image

The well-known encoded query is extended by a new part reflecting the Related List Condition:

RLQUERY problem_task.problem >=1 active=true^ ENDRLQUERY
boundary identifier for the beginning of a Related List Condition table name of related list and field name that references the parent record number of matching occurrences for the following condition filter condition for the records of the Related List boundary identifier for the end of a Related List Condition

To test out that new encoded query portion, it is not necessary to build a respective URL by yourself. Instead, use the Preview button (1) and click on the link with the number of matching records (2) right beside that button:

image

With the above configuration on the change_request table I wanted to find all Change Requests which have at least one referencing Change Task:

image

The resulting list represent exactly what was expected, but in the above screenshot you can also recognize some restrictions:

  1. You cannot use anymore the NLU search as well as the filter feature.
  2. You cannot save the query for later use.
  3. It is not possible to use the search fields in the table header.
  4. And additionally, there is no export option offered anymore.

So what else can we leverage on a list view with Related List Conditions?

For example, you still can create a Visual Task Board from the resulting list:

image

Can the extended encoded query be used for scripting?

Yes, it can! Right-click on the breadcrumbs part "Related List condition..." and copy the query into the clipboard:

image

The script returns exactly the same Change Request records as the list before:

image

With the classical approach, the script would be much more extensive!

What's your opinion? Can you think of any other possible uses? If so, feel free to leave them in the comments.

And if you want to see some more practical use cases for Related List Conditions I recommend the following video from @Robert Fedoruk: https://www.youtube.com/watch?v=gkzKzSXbwk0

image

View original source

https://www.servicenow.com/community/now-platform-articles/bring-back-related-list-conditions/ta-p/2312246