ServiceNow Encoded Query Translator

Live

Turn ^-separated encoded queries into plain English, edit them visually, and generate GlideRecord code and URLs.

Input

Encoded query, list URL or REST URL
Examples
Parsed 6 conditions · 1 sort

Plain English

whereActiveistrue
and
any of
Priorityis1 - Critical
Priorityis2 - High
andAssigned tois empty
andShort descriptioncontainsemail
andOpenedis after7 days ago
sortCreated (descending)

Builder

Edits rewrite the query above
where
and
or
andno value
and
and
sort

Output

background script · js
var gr = new GlideRecord('incident');
gr.addEncodedQuery('active=true^priority=1^ORpriority=2^assigned_toISEMPTY^short_descriptionLIKEemail^opened_atRELATIVEGT@day@ago@7^ORDERBYDESCsys_created_on');
gr.query();
while (gr.next()) {
    gs.info(gr.getValue('number') || gr.getUniqueValue());
}

Paste into System Definition › Scripts – Background on a sub-production instance to test.

What is an encoded query?

ServiceNow stores list filters as a compact string called an encoded query. Copy one from any list by right-clicking the filter breadcrumb and choosing Copy query. Scripts use the same format through GlideRecord.addEncodedQuery(), and REST calls through sysparm_query.

Pro tip: build the filter in the list view first, copy the query, and paste it into addEncodedQuery(). It's faster and less error-prone than chaining addQuery() calls.

Cheat sheet

^
AND
^OR
OR with the previous condition
^NQ
Start a new query; results are combined
ORDERBY / ORDERBYDESC
Sort ascending / descending
LIKE
Contains
STARTSWITH / ENDSWITH
Starts / ends with
IN / NOT IN
Is one of / is not one of
ISEMPTY / ISNOTEMPTY
Is empty / is not empty
^^
A literal ^ inside a value

How to translate a ServiceNow encoded query

  1. Paste the query. A raw encoded query, a sysparm_query value, a list URL or a full nav_to.do link all work.
  2. Read it in plain English. Each condition is shown as field, operator and value, grouped the way ServiceNow evaluates ^OR and ^NQ.
  3. Edit it visually. Change fields, operators and values without hand-editing carets.
  4. Copy what you need. GlideRecord code, a list URL, a Table API URL or a shareable link back to this page.

ServiceNow encoded query operators

Every condition is written as field + OPERATOR + value, with no spaces between them. These are the operators you will meet in list filters, scripts and REST calls.

OperatorMeaningExample
=is (equals)priority=1
!=is notstate!=7
LIKEcontainsshort_descriptionLIKEvpn
NOT LIKEdoes not containshort_descriptionNOT LIKEtest
STARTSWITHstarts withnumberSTARTSWITHINC00
ENDSWITHends with[email protected]
INis one of (comma-separated)stateIN1,2,3
NOT INis not one ofcategoryNOT INhardware,network
ISEMPTYis emptyassigned_toISEMPTY
ISNOTEMPTYis not emptyassignment_groupISNOTEMPTY
ANYTHINGany value, including emptycmdb_ciANYTHING
EMPTYSTRINGis an empty stringcorrelation_idEMPTYSTRING
< <= > >=less / greater than (numbers and dates)reassignment_count>2
BETWEENis between two valuessys_created_onBETWEENjavascript:gs.dateGenerate('2026-01-01','00:00:00')@javascript:gs.dateGenerate('2026-01-31','23:59:59')
ON / NOTONis (not) on a date or periodsys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()
RELATIVEGT / RELATIVELTis after / before a relative timesys_updated_onRELATIVEGT@hour@ago@24
MORETHAN / LESSTHANmore / less than a time span from another date fieldresolved_atMORETHANopened_at@day@after@3
SAMEAS / NSAMEASsame as / different from another fieldopened_bySAMEAScaller_id
GT_FIELD / LT_FIELDgreater / less than another fieldsys_updated_onGT_FIELDsys_created_on
DYNAMICmatches a dynamic filter, such as Meassigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe
INSTANCEOFis a class or any of its child classessys_class_nameINSTANCEOFcmdb_ci_computer
VALCHANGES / CHANGESTOvalue changes (business rule and notification conditions)stateCHANGESTO6

Joining conditions: ^, ^OR, ^NQ and ORDERBY

^OR binds tighter than ^, so active=true^priority=1^ORpriority=2 reads as "active and (priority 1 or 2)". Use ^NQ when you need OR between whole groups.

SyntaxMeaningExample
^AND: both conditions must matchactive=true^priority=1
^OROR with the condition right before itpriority=1^ORpriority=2
^NQNew query: OR between whole groups of conditionspriority=1^NQassigned_toISEMPTY
ORDERBY / ORDERBYDESCSort ascending / descending by a fieldactive=true^ORDERBYDESCsys_created_on
GROUPBYGroup results (lists and reports)active=true^GROUPBYassignment_group
^EQEnd-of-query marker added by some lists; safe to ignoreactive=true^EQ
^^A literal ^ inside a valueshort_descriptionLIKEA^^B

Common ServiceNow encoded query examples

Copy-ready queries for everyday filters. Open any of them in the translator to read or adapt it.

Using an encoded query in GlideRecord, list URLs and the REST API

The same string works everywhere. In URLs, encode it first: = becomes %3D, ^ becomes %5E and , becomes %2C.

Server script: GlideRecord.addEncodedQuery()
var gr = new GlideRecord('incident');
gr.addEncodedQuery('active=true^priorityIN1,2^ORDERBYDESCsys_created_on');
gr.query();
while (gr.next()) {
  gs.info(gr.getValue('number') + ' ' + gr.getValue('short_description'));
}
List view URL
https://<instance>.service-now.com/incident_list.do?sysparm_query=active%3Dtrue%5EpriorityIN1%2C2%5EORDERBYDESCsys_created_on
REST Table API (GET)
https://<instance>.service-now.com/api/now/table/incident?sysparm_query=active%3Dtrue%5EpriorityIN1%2C2%5EORDERBYDESCsys_created_on&sysparm_limit=10

Frequently asked questions

What is an encoded query in ServiceNow?

An encoded query is the compact text form of a list filter, such as active=true^priority=1. Each condition is a field, an operator and a value, and conditions are joined with ^ (AND), ^OR and ^NQ. The same string works in list URLs (sysparm_query), in scripts through GlideRecord.addEncodedQuery(), and in the REST Table API.

How do I copy the encoded query from a list?

Filter the list, then right-click the last part of the filter breadcrumb and choose Copy query. You can also take the sysparm_query value from the list URL, or call gr.getEncodedQuery() in a script. Paste any of these into the translator above, including full nav_to.do links.

What is the difference between ^OR and ^NQ?

^OR joins one condition to the condition right before it, as in "priority is 1 or 2". ^NQ starts a completely new query, so the result is every record that matches the first group of conditions or the second group, as in "(active and P1) or (unassigned)".

How do I use an encoded query in a GlideRecord script?

Call gr.addEncodedQuery('active=true^priority=1') before gr.query(). Building the filter in the list view first and copying the query avoids typos in field names and operators. The translator also writes the equivalent addQuery() lines if you prefer them.

Why does my encoded query return every record?

By default ServiceNow ignores conditions on field names it does not recognise, so a typo such as prority=1 quietly matches everything. Check the field names in the translator, or set the system property glide.invalid_query.returns_no_rows to true so that invalid queries return no rows instead.

How do I filter on "Me" or "One of my groups"?

Use dynamic filters: assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe means "assigned to me", and assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744 means "assignment group is one of my groups". A script value such as assigned_to=javascript:gs.getUserID() also works.

Does this tool connect to my ServiceNow instance?

No. The translator runs entirely in your browser and never asks for instance credentials. Nothing you paste is uploaded, so it is safe to use with queries from tickets, Slack messages or production lists.