Code Search
Search ServiceNow scripts with Classic or GraphQL mode, filter results, and export matching code.
Last updated: November 2, 2026
Code Search
Search code across your instance using the built-in code search API:
/code changeutils
Code search can also be triggered via:
- Selected text and extension context menu
- Monaco editor context menu
The code search page supports two modes: Classic (using the ServiceNow Code Search API) and GraphQL (using the Now Platform GraphQL API).
/code opens in the mode you used last, and the slash palette shows a small Classic or GraphQL badge on the /code row so you can see which one that is before you press Enter. To force a mode for one search, add -c (Classic) or -g (GraphQL) after the search term:
/code getValue -g
Every search opens in its own tab, so earlier results stay available.
Use the underlined ab button beside the search box to match complete words or identifiers only. The setting applies to both Classic and GraphQL mode and is remembered for your next Code Search session. GraphQL progressively pages until it fills the selected exact-match limit or exhausts the candidates; Classic warns if it reaches ServiceNow's Code Search server cap.
Code Search for Current Table
Use /codecurrent to search code filtered to the table you're currently viewing:
/codecurrent getValue
On a sys_script_include form, this searches for "getValue" in the sys_script_include table only.
Classic Mode
Classic mode uses the built-in ServiceNow Code Search API. It relies on Code Search Groups configured on your instance, and searches the tables defined in the selected group.
Classic mode supports the table: syntax: if you include table:sys_script in your query, the search is limited to that table within your search group. If the table is not part of the group, a message is shown. field: filtering is only available in GraphQL mode.
The last-used search group is remembered per instance, so you don't need to re-select your preferred group every session.
Custom Code Search Commands
You can create custom slash commands that open Code Search with pre-filled filters. See Custom Code Search Commands for details.
GraphQL Mode Pro
GraphQL mode provides a faster, more powerful search experience. It uses the Now Platform GraphQL API to search across a curated index of ~450 code-related tables and automatically layers on top the tables and fields from your selected Code Search Group (sn_codesearch_search_group). Custom tables (including u_* and x_*) and admin-configured search_fields / additional_filter from sn_codesearch_table are honored out of the box, so GraphQL mode is a strict superset of Classic for your configured scope.
Search Syntax
GraphQL mode supports advanced search syntax:
| Syntax | Description | Example |
|---|---|---|
word1 word2 | Match all words (AND). Records must contain every word in any searchable field. | GlideRecord query |
"exact phrase" | Match an exact phrase as a single term. Wrap in double quotes. | "var gr = new" |
table:name | Restrict search to tables matching the name. Partial match on table name and label. | table:sys_script getValue |
field:name | Search only in the specified field(s). | field:script_plain myFunction |
These can be combined freely. For example:
table:sys_script field:script "GlideRecord" addQuery
This searches only tables matching "sys_script", only in the "script" field, for records containing the phrase "GlideRecord" and the word "addQuery".
Options
| Option | Description |
|---|---|
Match whole word (ab) | Match complete words or identifiers rather than substrings. This shared search-box option also applies in Classic mode. |
| Active only | Restrict to records where active = true (for tables that have an active field). Off by default so you see the full picture; every record header shows an Active or Inactive chip so you can tell them apart at a glance. An additional_filter configured on the group or as a local override takes precedence over this auto-added condition. |
| Extended search | Optional. Discovers additional tables from sys_dictionary beyond the curated list. Usually not needed: your selected Code Search Group and any local overrides are already layered in. Enable this only when you want a wider auto-discovery sweep. |
| Show long strings | Controls the inline collapse of long non-whitespace runs (base64 payloads, JWTs, data URLs, minified JS chunks). When off, runs of 80+ characters without whitespace render as a ⋯ 2,431 chars ⋯ pill you can click to expand. A yellow match pill on the collapsed blob means your term was found inside it, so hits are never hidden silently. |
| Results per table | Limit the number of matching records returned per table (10, 25, 50, 100, or 250). Higher limits slow down per-batch responses. |
| Updated date range | Filter results by last updated date. Use presets (7 days, 30 days, 90 days, 1 year) or a custom range. |
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Enter | Execute search |
Esc | Cancel a running search |
Cmd/Ctrl + K | Focus the search input |
For search groups, field overrides, inaccessible tables, and parent-record resolution, see Code Search Configuration.
Results Layout
Results render in a two-pane view with a sticky Tables sidebar on the left and the active table's records on the right:
- Click any table in the sidebar to focus just its hits: the other tables hide.
- Click All tables at the top of the sidebar to return to the full list.
- Tables are sorted by match count; the hit count is shown next to each entry.
- A table filter appears above the list when there are more than 8 tables, so you can narrow a long list like
emailorsys_script. - While a table is focused, a Filter records box appears above the right pane. Type to hide records in that table whose content doesn't contain the term (useful for zeroing in on a specific script include name inside a large hit count).
- Drag the divider on the right edge of the sidebar to resize it; the width is remembered locally.
- Keyboard shortcuts:
j/kto step through tables,Escto clear the active field filter first and then fall back to All tables. - Only the search bar stays sticky while you scroll: the rest of the options bar hides so you keep full vertical space for results.
- On narrow viewports (< 900px wide) the sidebar collapses above the results.
This layout applies to both Classic and GraphQL modes.
Sidebar Detail Mode & Field-level Filtering
Toggle Details at the top of the Tables sidebar to switch the list into a richer layout:
- The technical table name is shown below its human label in a monospace font.
- Each table expands into small field pills listing every field that had at least one hit, with per-field hit counts.
- Click any field pill to filter within that table to just records that match in that field, useful for isolating, say,
scripthits versusdescriptionhits onsys_script_include. The active filter shows up as aField: script ×chip next to the Filter records box. - Clicking a pill from the All tables view auto-focuses the owning table first.
- Press
Escto clear the field filter; pressEscagain to return to All tables.
Field-type Badges
Every record shows compact colored pills in its header summarizing which kinds of fields matched, so you can skim a long list and tell code hits apart from descriptive text without expanding each card:
| Badge | Field types it represents |
|---|---|
SCRIPT | script, script_plain, script_server, workflow, email_script |
CLIENT | script_client |
EXPRESSION | expression, formulas |
HTML | html, translated_html |
CSS | css |
XML | xml |
JSON | json, json_translations |
CONDITION | conditions, condition_string, encoded query fields |
TEMPLATE | glide_var, template_value |
TEXT | string, translated_text (name, description, short_description, etc.) |
The same chip is shown next to the Field: heading when you expand a record, so you can see exactly which field matched at what line. Types are resolved from the curated codesearch.json when available, with a name-based heuristic fallback so custom tables and ad-hoc fields still get sensible badges.
Download JSON
After a GraphQL search completes, a Download JSON button appears in the field index bar. It exports the full last search to a .json file: the search term and options, plus every matched table, record, field and the surrounding line context. Handy for sharing findings, scripting follow-up changes, or feeding results into AI tooling. Matches are exported as excerpts (context and matching lines), not full field bodies.
Help
Click the Help button in the field index bar for a quick reference of all search syntax, options, and keyboard shortcuts directly on the page.