Custom Commands
Create your own SN Utils slash commands with custom searches, URL templates, and context menu integration.
Last updated: January 24, 2026
Custom commands let you turn repeated ServiceNow navigation, searches, and small page scripts into short slash commands that work across your instances. The main editor lives in Manage > Commands (open it with the popup gear icon or /manage), and /newcmd can start a new command directly from the slash palette.
Modern custom commands are edited through the form UI so names, URLs, fields, sharing, and sync stay predictable. Legacy pre-v10 JSON commands remain supported separately under Manage > Advanced > Legacy JSON Editing.
Creating a Basic Custom Command
Let's create a custom incident search command:
- Open the incident table with filters:
/incident -f - Create a filter:
Number CONTAINS $0 Or Short Description CONTAINS $0 - Click the Updated column to sort by Updated descending
- Open the Manage page (gear icon in the popup header, or
/manage) and go to the Commands tab - Click New Custom and choose Prefill from Open Tabs
- Select the incident tab from the suggestions — URL, Hint, and Fields get prefilled from your current list
- Name the command
inc - Adjust fields to
number,short_description - Click Save
Test with /inc sap and Right Arrow — you'll see results with number and short description fields. This command works across all your instances!
Creating from the Slash Palette (/newcmd)
You don't have to leave the page you're on. Open the slash palette and type /newcmd to jump straight to the Commands tab with the editor in the "new" state, focused on the command name. Add a description after the shortcut and /newcmd will sniff what you typed and prefill the right field:
| What you type | Where it lands |
|---|---|
URL or path — incident_list.do?sysparm_query=active=true, /sp?id=..., https://... | URL field (URL mode) |
Script — javascript:alert(g_form.getTableName()) or (function(){…})() | Script editor (Script mode, javascript: prefix decoded) |
Bare fields list — number,short_description,priority | Fields field |
Encoded query — active=true^priority=1 | URL field as &sysparm_query=active=true^priority=1 |
| Anything else (natural language) | Description field |
Single-token inputs like /newcmd incident are treated as natural language — too ambiguous to assume "this is a table name" — so they land in the description.
If your input is natural language and you're on Pro, the AI Builder opens and runs the prompt for you with the current page as context — review and Save. On the Free plan the description is prefilled into the editor so you have a starting point for writing the command yourself.
Examples:
/newcmd sys_user_list.do?sysparm_query=nameLIKE$0— URL command, ready to name and save./newcmd javascript:g_form.save()— bookmarklet → script command in Monaco./newcmd number,short_description,assigned_to— fields list to attach to whatever URL you set./newcmd open the caller's user record in a new tab(Pro) — AI generates the command with page context.
Commands Tab Overview
The Commands tab on the Manage page is where you create, edit, and manage all your slash commands.
- Search existing commands — Click a result to edit it; internal Built-in Pro actions are visible but locked because their behavior is not a portable URL or script definition
- New Custom — Create a new command from scratch or prefill from open tabs
- URL / Script action — Use URL mode for navigation and list searches, or Script mode for JavaScript that runs in the page context
- Variables help — Quick reference for
$0,$sysid,$table,$encodedquery,$ext/, and inline result fields - Fields and overwrite URL — Configure inline search results and optionally send selected rows to a different target URL
- Inline Only — Keep a command as an inline-result picker instead of opening the list on Enter
- Save as Custom — Select a regular built-in, pack, or legacy command and save your own editable custom copy; internal Built-in Pro actions cannot be cloned
- Sharing — Keep commands private or share them with your team when Team Space is available
- Marketplace — Install curated Content Packs with ready-made commands
URL vs Script Commands
Most commands are URL commands. They open a ServiceNow path, absolute URL, or another slash command alias and can include variables such as $0, $table, or $sysid.
Use Script commands when the command should run JavaScript on the current ServiceNow page. Script mode uses Monaco, auto-minifies the saved action, and can call SN Utils helpers such as snuGetGForm(), snuShowModal(), and snuCodeSearch().
If you paste a javascript: bookmarklet, the editor switches to Script mode and decodes the script for editing. See Variables & Helper Methods for the full helper reference.
Sync and Availability
Custom commands are available in the form-based Commands tab. Pro features such as cloud sync, Team Space sharing, and AI-assisted generation build on top of the same command format.
Command names should stay short and URL-safe. For cloud sync, use at least one letter or number and only letters, digits, _, -, or modifier punctuation such as ?, !, ., +, :, @, #, ~, ^, =. Unsupported names can be saved locally, but they will not sync until renamed.
URL Variables
| Variable | Description |
|---|---|
$0 | Search term |
$1, $2... | Individual words from the search term |
$date | Today's date (YYYY-MM-DD) |
$sysid | Current record sys_id |
$table | Current table name |
$TableName | PascalCase form of the current table name for use as a JS identifier (e.g. incident → Incident, sys_user → SysUser). Falls back to Record when no table is in scope |
$encodedquery | Current list/filter encoded query (when available) |
$fieldname | Value from inline result fields |
$ext/ | SN Utils extension asset base URL |
Need the full reference with examples and script helpers?
See: Variables & Helper Methods
Overwrite Target URL
Some commands filter records but should open a different page. Use "Overwrite target URL" for this.
Example: The /uibe command searches experiences but opens UI Builder directly:
- URL with
sysparm_query=— Recognized as table filtering command - Fields — First two display in popup; additional fields (like
admin_panel.sys_id) available for target URL - Overwrite URL — Uses field variables like
$admin_panel.sys_id
Running /uibe util:
- Run command with search term
- Results show inline (default behavior with overwrite)
- Links point to UI Builder, not the record
- Use CTRL-Enter to open classic list instead
- Switches still work!
Custom Code Search Commands
You can create custom commands that open Code Search with pre-filled filters, so you don't need to type the same table: and field: syntax every time.
Using snuCodeSearch() (recommended)
Create a Script command that calls the snuCodeSearch() helper with your preferred filters plus $0 for the user's search term:
- Open the Manage page and go to the Commands tab
- Click New Custom > Start Blank
- Name the command (e.g.
codebrfor Business Rules) - Switch to the Script tab
- Enter:
snuCodeSearch('table:sys_script field:script ' + '$0');
Now /codebr GlideRecord opens Code Search filtered to sys_script records containing "GlideRecord" in the script field.
You can combine multiple tables and fields:
snuCodeSearch('table:sys_script table:sys_properties field:script "GlideRecord" ' + '$0');
Using //code alias (alternative)
You can also use the // URL prefix to alias the built-in /code command:
- Name the command (e.g.
codebr) - Set the URL to:
//code table:sys_script field:script $0
This expands /codebr mySearch into /code table:sys_script field:script mySearch.
Built-in /codecurrent
There's also a built-in /codecurrent command that automatically pre-fills Code Search with the current table context. On a sys_script_include form, /codecurrent getValue searches for "getValue" filtered to the sys_script_include table.
See also: snuCodeSearch() in the helper methods reference.
Context Menu Integration
Add #contextmenu to a command's URL to make it available in the right-click context menu:
After saving:
Custom Switches
Custom switches have their own dedicated Switches tab on the Manage page. Start with the guide: Slash Switches.
Advanced examples are also available on the Switches page.
Legacy JSON Editing
Commands created before the form-based editor remain editable as raw JSON under Manage > Advanced > Legacy JSON Editing — and only there. Modern custom commands have no raw-JSON path by design; they live on the form-based Commands tab so inputs stay validated and cloud sync stays predictable.
See Legacy JSON Editing for the full workflow, the Convert-to-Custom flow that migrates grandfathered entries into the modern format, and the automatic local snapshots captured before every save.