Quantum Code Search

James Bustard
Tera Expert

After using the OOTB code search tool for years I decided it was time for an upgrade. Quantum Code Search is my take on a replacement; it wraps the out-of-the-box sn_codesearch API in a modern, feature-rich interface and works across both UI16 and Polaris (Next Experience).

 

JamesBustard_1-1776231199776.png

 

Core Search

Search across all scripted artefacts in your instance with results grouped by record type in a clean, collapsible accordion layout. Syntax highlighting brings code matches to life with colour-coded keywords, strings, functions, comments, and operators. Search term matches are visually highlighted within each code snippet so you can spot what you're looking for at a glance.

 

Record Details on Demand

Expand any result to see key metadata loaded on demand: active status, scope, update set, target table, created/updated timestamps, and contextual fields like When, Type, Order, and Client Callable that adapt based on the record type. No need to open the record just to check its details.

 

Flexible Result Views

Toggle between three ways to explore your results. The default view groups results by record type. "Group by Table" reorganises everything by target table, giving you a three-level accordion of Table → Type → Record. "Sort by Updated Date" flattens results into a chronological list showing who changed what and when (handy if you're looking for code which may exist across the environment, when you're only interested in the most recent changes).

 

Filtering and Navigation

A sidebar appears alongside results, letting you jump to or isolate specific record types or tables with a single click. A type-ahead filter in the sidebar narrows the list further. A second filter bar lets you search results by record name. Both filters stack together so you can drill down quickly across large result sets.

Hide Inactive Filter out inactive records server-side so you only see what's currently in play. Useful on mature instances where search results are cluttered with disabled scripts.

 

Record Lookup Mode

Switch from code search to a general-purpose record finder. Search for Tables, Users, Groups, Roles, or Update Sets by name. Single matches navigate directly to the record. For Update Sets, you can see the current set highlighted and switch your active update set with a "Make Current" button without leaving the page. For tables, you can jump straight to the definition or open a list view of its records.

 

Sys ID Detection

Paste a 32-character sys_id into the search bar and Quantum Code Search will find the record across your instance, checking common base tables first, then scanning deeper, and navigates you straight to it.

 

Extending What Gets Searched

Quantum Code Search uses ServiceNow's built-in sn_codesearch API under the hood, which means the tables and fields it searches are fully configurable. Out of the box, the Default Search Group covers around 21 common script tables like Business Rules, Client Scripts, and Script Includes, but you can expand this to include any table and any field on your instance.

 

To add a new table or field to the search, navigate to Code Search Tables (sn_codesearch_table). Each record specifies a table name and a comma-separated list of fields to index. Create a new record, set the table, add the fields you want searched (e.g. script, condition, template), and associate it with the Default Search Group (sn_codesearch.Default Search Group). Your new table will be included in the next search, no app restart or cache flush required. This is especially useful if you have custom scoped tables with script fields, or if you want to search fields that aren't included by default, like filter conditions, email templates, or workflow activities.

 

Dark and Light Themes

A full dark theme is the default, with a carefully tuned light theme available via toggle. Both themes carry through to syntax highlighting, the sidebar, detail cards, and every UI element. Your preference is saved and persists across sessions.

 

Hide Navigation Mode

Run Quantum Code Search as a standalone full-page experience without the ServiceNow navigation frame. The navbar icon respects this preference and opens the correct URL automatically, no flash, no double-load.

 

Navbar Icon

A code icon (</>) is injected into the ServiceNow header bar (in both UI16 and Polaris) for one-click access. It respects your navigation preference and opens the Quantum Code Search UI Page in a in a new tab.

JamesBustard_2-1776231410013.png

 

Persistent Preferences

All toggle states (Group by Table, Hide Inactive, Sort by Date, Record Lookup, Record Lookup type, Hide Navigation, and theme) are saved as user preferences and restored automatically on your next visit.

A note on development
Much of this tool was built with the assistance of Claude (Anthropic's AI). Most of the code has been reviewed, tested, and refined by hand across both UI16 and Polaris environments.

 

Installing

The attached update set contains everything you need to get it up and running. The following artefacts are included:

  • Access Control (quantum_code_search)
  • Access Control (QuantumCodeSearchAjax)
  • Access Role (QuantumCodeSearchAjax.admin)
  • Access Role (quantum_code_search.admin)
  • Macro (quantum_code_search)
  • Script Include (QuantumCodeSearch)
  • Script Include (QuantumCodeSearchAjax)
  • UI Page (quantum_code_search)
  • UI Script (quantum_code_search_icon)

All artefacts are protected by the admin role. The navbar icon and search page will only be visible to admin users.

Quantum Code Search can be downloaded from the community share HERE.

0 REPLIES 0