Snippet Variables

Use {{variables}} in snippets to insert live data from the current record or your user profile. Variables are resolved automatically when copying snippets.

Snippet variables let you create dynamic templates that pull in live data when you use them. Instead of manually replacing placeholder text, variables like {{caller_id.first_name}} or {{$name}} are resolved automatically with real values from ServiceNow.

How It Works

Variables are resolved in two scenarios:

In Text Fields (Work Notes, Comments, etc.)

When you insert a snippet into a regular text field (work notes, comments, additional comments), any {{variables}} are resolved with live data before insertion. This means you get personalized text directly in the field — no manual editing needed.

Clipboard Mode (Outside Editable Fields)

When you open the snippet popup (⇧⇧) outside a script editor or text field, the popup enters clipboard mode:

  1. A clipboard badge appears in the header
  2. The footer shows Copy instead of Insert
  3. Variables are resolved with live data
  4. Pressing Enter copies the resolved text to your clipboard

This is useful when you want to prepare text for pasting into emails, chat, or other applications outside ServiceNow.

In Script Editors (Monaco)

When inserting into a script field (Monaco editor), variables are not resolved — the raw {{variable}} text is inserted as-is. This is intentional so you can write code that references variables literally. Tab stops like ${1:placeholder} continue to work normally in script editors.

Variable Syntax

Variables use double curly braces: {{variable_name}}

There are two types of variables:

Record Variables

Record variables pull data from the record you're currently viewing. They use the field name directly, and support ServiceNow dot-walking.

VariableResolves To
{{short_description}}The record's short description
{{number}}The record's number (e.g., INC0012345)
{{caller_id}}The caller's display value
{{caller_id.first_name}}The caller's first name (dot-walked)
{{assigned_to.email}}The assigned user's email (dot-walked)

Record variables work on any form — incidents, changes, requests, or any other table. The extension detects the current table and sys_id automatically.

User Variables

User variables pull data from your own logged-in profile. They are prefixed with $.

VariableResolves To
{{$first_name}}Your first name
{{$last_name}}Your last name
{{$name}}Your full name
{{$email}}Your email address
{{$user_name}}Your username

User variables are resolved instantly without an API call, since the data is available locally.

Examples

Personalized Greeting

Hi {{caller_id.first_name}},

Thank you for reaching out. I've reviewed your request and will follow up shortly.

Kind regards,
{{$first_name}}

If you're on an incident where the caller is George Miller and you're logged in as Arnoud, this resolves to:

Hi George,

Thank you for reaching out. I've reviewed your request and will follow up shortly.

Kind regards,
Arnoud

Quick Status Update

{{number}} - {{short_description}}
Status: In Progress
Assigned to: {{$name}}

Escalation Note

Hi {{assigned_to.first_name}},

I'm escalating {{number}} to your group. The caller ({{caller_id}}) reported: {{short_description}}.

Please review at your earliest convenience.

Thanks,
{{$first_name}}

Behavior Details

When Variables Can't Be Resolved

If a variable cannot be resolved (e.g., you're not on a record page, or a field doesn't exist on the current table), the variable stays as-is in the copied text. For example, {{caller_id.first_name}} would remain literally as {{caller_id.first_name}} if there's no record context.

This lets you safely use the same snippet both on and off a record form — it just copies the raw template when context isn't available.

Preview Pane

When in clipboard mode, the preview pane at the bottom of the popup shows the resolved output with live data filled in. This lets you verify the result before copying.

Insert Mode vs Clipboard Mode

Script Editor (Monaco)Text Field (Work Notes)Clipboard Mode
WhenCursor in a script fieldCursor in a text areaOutside any editable field
ActionInsert raw snippetInsert resolved snippetCopy resolved snippet
VariablesLeft as-isResolved with live dataResolved with live data
Tab stopsWork normallyStripped to placeholder textStripped to placeholder text
Footer↵ Insert↵ Insert↵ Copy

Mixing Variables with Code

Variables use {{double curly braces}} specifically to avoid conflicts with JavaScript code (single {braces}) and snippet tab stops (${1:placeholders}). You can safely have all three in the same snippet:

// {{$name}} - {{number}}
var gr = new GlideRecord('${1:table_name}');
gr.addQuery('caller_id.name', '{{caller_id}}');
gr.query();

When inserted into an editor (insert mode), the {{variables}} stay as-is and the ${1:...} tab stops work normally. When copied (clipboard mode), the {{variables}} are resolved and tab stops are stripped.