Skip to content
Tutorials Center
My learning

Topics

Lesson 15 of 39 ยท Forms, Lists and UI Policies

Lists, Filters and Encoded Queries

Work fast in ServiceNow lists: the condition builder, AND/OR logic, saved filters, grouping, inline editing, personalizing columns, and reading and writing encoded queries.

Lists are where most people spend their day: queues of incidents, tasks to approve, users to review. A list shows records of one table in rows and columns, and a filter decides which rows appear. Knowing the condition builder and the encoded query that powers it will make you very quick.

Reading a list

  • The title shows the table and number of records.
  • Column headings sort when clicked; the right-click menu offers Sort, Group By, Hide and Show Visual Task Board on some tables.
  • The breadcrumb bar (in the filter area) shows the active conditions as clickable pieces; you can remove one piece by clicking it.
  • Paging controls at the bottom change the page; the rows per page setting is a personal preference.
  • Inline editing: double-click a cell to edit it, subject to ACLs and list-edit settings.
  • Context menu on a row: Open, Copy sys_id, Assign to me, and options defined by UI actions.

Use the gear icon (Personalize List) to choose which columns appear and in what order, for yourself only. To change the default list for everyone, an administrator uses Configure > List Layout.

The condition builder

Click Filter (the funnel icon). Each row is field - operator - value:

  • Field can be dot-walked through references (Caller > Department).
  • Operator depends on the type: is, is not, starts with, contains, is empty, between, on today, is one of, less than and so on.
  • Press AND to add a condition that must also match, or OR to match either. Mixed AND/OR filters are easy to misread, so check the breadcrumb after you press Run.
  • Press Run to apply, Save to name the filter (stored for you or shared), Clear to reset.

A filter can also compare a field with another field (for example, Updated is later than Due date) and use dynamic values: Me, My Group, Today, Last 7 days.

Encoded queries

Behind the builder is a compact string called an encoded query:

  • ^ means AND, ^OR means OR, ^NQ starts a new query (a union).
  • A condition is field + operator + value, such as active=true, priorityIN1,2, short_descriptionLIKEvpn, assigned_toISEMPTY.
  • Examples:
TEXT
active=true^priority=1
active=true^priority=1^ORpriority=2
caller_id.department.name=Finance^assignment_group=<sys_id>
opened_atONLast 7 days@javascript:gs.daysAgoStart(7)@javascript:gs.daysAgoEnd(0)

Where you meet encoded queries:

  • URL: incident_list.do?sysparm_query=active=true^priority=1.
  • Right-click a breadcrumb and choose Copy query; paste it into a script or a URL.
  • Scripts: gr.addEncodedQuery('active=true^priority=1').
  • Reports, notifications, SLAs: they all store the same format.

Common operators:

Operator text Meaning Example
= / != equals / not equal state=2
LIKE / NOTLIKE contains short_descriptionLIKEvpn
STARTSWITH / ENDSWITH text edges numberSTARTSWITHINC
IN / NOT IN one of a list priorityIN1,2
> >= < <= comparison reopen_count>2
ISEMPTY / ISNOTEMPTY empty test assigned_toISEMPTY
BETWEEN range priorityBETWEEN1@3
Python Parse and apply an encoded query (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Group by, aggregates and saved lists

  • Group By (right-click a column heading) folds rows under group headers with counts, handy for "incidents per assignment group".
  • Show / Hide columns and Sort persist for you.
  • Save filter: name the filter in the Condition builder; you choose who can use it.
  • Reports and Dashboards: use the same filters for charts.
  • Export: the list context menu offers Export > Excel / CSV / PDF, respecting ACLs.
  • Update selected / Update all: bulk change via the footer (admin rights).

Update All changes every record that matches the filter, not just those on screen. Run the filter first, check the count in the title, and work in a development instance when learning.

Personal versus shared

Filters you save are personal unless shared. List layouts (columns for all users), List Control (hiding New, edit, etc.) and Related list settings are configuration and travel in update sets. Personalization is not part of an update set.

Python Group by and count (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does ^ mean in an encoded query?

    ^ joins conditions with AND; ^OR adds an alternative to the previous condition.
  2. 2. How can you copy the query behind a filter?

    The breadcrumb context menu offers Copy query, giving you the encoded string.
  3. 3. What is the difference between Personalize List and List Layout?

    Personalization is a per-user preference; Configure > List Layout is shared configuration.
  4. 4. Which encoded query finds incidents with priority 1 or 2?

    IN matches any value in the comma list; priority=1^priority=2 would require both at once.

Summary

  • Lists show one table's records; filters narrow them.
  • The condition builder writes encoded queries (^ AND, ^OR OR).
  • Copy a query from the breadcrumb to reuse it in URLs, scripts and reports.
  • Be careful with Update All and keep personal and shared settings apart.

Next: UI Policies