Free toolRuns in your browser · nothing is sent or stored
GlideRecord query builder
Pick a table, add conditions and choose what to return. Get a clean server-side GlideRecord or GlideAggregate script, plus the encoded query to paste into a list filter.
Your query
Your script
Works in addEncodedQuery() and list filters. A descending sort stays in the script (orderByDesc), so only an ascending sort is added here as ORDERBY.
Starter code. Read it, then test it in a sub-production instance. An update script starts as a dry run that only writes to the log.
Planning AI on top of these queries? Read ServiceNow AI integration: what actually works and 5 CSM workflows AI can take off your team’s plate, or see the ServiceNow AI integration service.
How it works
01
Pick the table and the job
Read rows, update rows in a loop, count rows by group, or read rows with ACLs applied. Each mode writes the pattern that fits it, not one script for everything.
02
Add conditions in plain words
Field, operator, value. Mark a row OR to group it with the row above, the same way the list filter does. Operators map to the real addQuery() and encoded-query spellings.
03
Copy the script or the encoded query
The script tab is ready for a background script or Fix Script; the encoded query works in addEncodedQuery() and list filters. Both say in one line what they will match.
04
Guards are built in
Every read has a setLimit(). Updates start as a dry run that only logs. Counts use GlideAggregate. Values are read with getValue() so you get strings, not live field objects.
Questions
Does this tool connect to my ServiceNow instance?
No. It only writes text in your browser. Nothing is sent anywhere, and it never sees your instance, your tables or your data. You copy the script and run it yourself.
Where do I run the generated script?
Anywhere server-side JavaScript runs: Scripts - Background for a quick check, a Fix Script, a Script Include, a business rule or a scheduled job. Run it in a sub-production instance first, especially the update version.
Why does the script use CONTAINS while the encoded query uses LIKE?
They are two spellings of the same idea. ServiceNow’s docs list CONTAINS and DOES NOT CONTAIN as the addQuery() operators, while encoded query strings (list filters, addEncodedQuery) use LIKE and NOT LIKE.
Why GlideAggregate for counting instead of getRowCount()?
getRowCount() makes the instance fetch the matching records just to count them. GlideAggregate asks the database for the count, which is far lighter on a big table. ServiceNow’s own GlideRecord docs recommend it when you only need the number.
When should I use GlideRecordSecure?
When the script acts for a real user and must respect what that user is allowed to see, for example in a client-callable Script Include. Plain GlideRecord runs without ACL checks, which is right for system jobs and wrong for anything a user can trigger to read data they should not see.
The next step
Want a person to look at your result?
A free tool gives you a first answer. The ServiceNow AI Integration service turns it into a plan for your business, with a fixed quote before any build.
Start a project