Blog

Top Level and Dependent Conditions

There are two ways to make conditional statements using the filter functionality in ServiceNow.

  1. Dependent

  2. Top Level

So what is the difference between these buttons? Let's go into greater detail on these two options.

newquery0.jpg

Dependent Condition

A dependent condition is what I have used 99% of the time. A dependent condition is when you click next to the the field to add more conditions. It is kind of like a basic where clause in SQL.

Sometimes I encounter the need to have more than one query for my filter. That's when a Top Level Condition helps out.

Top Level Condition

A Top Level Condition is when you use the and, or symbols at the top of the filter. When you click the OR Top level condition, it adds a "New Query" line in the filter.

newquery3.png

Actually when you copy this query, you can see it actually uses the NQ operator in the url. NQ means New query.

https://<your_instance>/cmdb_ci_list.do?sysparm_query=sys_class_name%3Dcmdb_ci_appl%5EORsys_class_name%3Dcmdb_ci_server%5Esys_updated_on%3Ejavascript%3Ags.endOfLastYear()%5ENQsys_class_name%3Dcmdb_ci_app_server_java

Example Difference

Here's an example. If I wanted to search for all the Incidents where:

If you do only top level queries, you won't get any results at all. That's not right.

  • Active Incidents for Database Group

  • Closed Incidents for Software Group

If you do only dependent queries, you will get all the incidents. That's not correct either.

Now a combination of dependent and top level queries, you can get the correct results.

Hope that helps! Note that this article is an extension to the Wiki article on OR Conditions. Be sure to check that out as well.

http://wiki.servicenow.com/index.php?title=Using_Filters_and_Breadcrumbs