Variables & Helper Methods
Complete reference for slash command variables and helper methods available in custom URL and Script commands.
This page documents all placeholders and helper methods that can be used in custom slash commands.
Variable Reference
Input Variables
| Variable | Meaning | Example Input | Output |
|---|---|---|---|
$0 | Entire text after the command name | /inc vpn issue | vpn issue |
$1, $2, ... | Space-separated tokens from $0 | /inc vpn issue | $1 = vpn, $2 = issue |
Context Variables
| Variable | Meaning | Notes |
|---|---|---|
$table | Current table name | Resolved from form, list, workspace, portal, Studio and supported builders |
$sysid | Current record sys_id | Resolved when a current record context exists |
$encodedquery | Current list/filter encoded query | Available when the context exposes query/filter information |
Inline Result Variables
When a command returns inline results and you configure fields, you can reference those fields in Overwrite target URL:
| Pattern | Meaning |
|---|---|
$fieldname | Value of that field on the selected row |
Example:
Overwrite target URL: /now/builder/ui/${admin_panel.sys_id}
(Using the actual placeholder style from slash commands: $admin_panel.sys_id.)
Extension Variable
| Variable | Meaning |
|---|---|
$ext/ | SN Utils extension asset base URL |
Example:
$ext/html/settingeditor.html?setting=slashcommand_legacy
Helper Methods for Script Commands
Script commands run in the page context, so you can call SN Utils helper methods directly.
snuGetGForm()
Returns a unified g_form reference across classic UI and supported workspace scenarios when available.
const form = snuGetGForm();
if (form) {
const table = form.getTableName();
const sysId = form.getUniqueValue();
console.log(table, sysId);
}
snuGetDocument()
Returns the active content document (iframe-aware), useful when the rendered UI is inside gsft_main.
const doc = snuGetDocument();
const title = doc.querySelector('title')?.textContent;
console.log(title);
snuGetWindow()
Returns the active content window (iframe-aware), useful for APIs scoped to the content frame.
const win = snuGetWindow(); console.log(win.location.href);
Practical Examples
Open filtered incidents by full input
incident_list.do?sysparm_query=short_descriptionLIKE$0
Open specific record by tokenized input
incident.do?sys_id=$1
Reuse current context
sys_update_version_list.do?sysparm_query=name=$table_$sysid
Jump to extension-managed page
$ext/html/settingeditor.html?setting=slashcommand_legacy
Notes
- If a context variable cannot be resolved in the current page, it resolves to an empty string.
- Prefer URL commands for simple navigation and filtering.
- Use Script mode only when you need conditional logic or DOM/API interaction.