There are two ways to make conditional statements using the filter functionality in ServiceNow.
- Top Level
So what is the difference between these buttons? Let's go into greater detail on these two options.
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.
Actually when you copy this query, you can see it actually uses the NQ operator in the url. NQ means New query.
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.