Code Snippets

Store, organize, and quickly insert reusable code snippets in any ServiceNow script field.

Code Snippets is a library of reusable code templates that you can insert into any ServiceNow script field with a quick keyboard shortcut. Instead of retyping common patterns or digging through old scripts, press ⇧⇧ (double Shift) to open the snippet search and insert code in seconds.

Code Snippets quick search popup showing snippet results <!-- Screenshot needed: Snippet quick search popup over a script field with a few results -->

Quick Start

  1. Press ⇧⇧ (Shift twice quickly) while your cursor is in a script field
  2. Type a few characters to search
  3. Select a snippet from the results
  4. The code is inserted at your cursor position

That's it. The popup appears over your editor, you search, select, and the snippet is inserted.

Snippet Types

Snippets come from three sources, listed in priority order (highest priority wins when names overlap):

Custom Snippets (Highest Priority)

Snippets you create yourself. These are personal and override any other snippet with the same name.

Team Snippets

Snippets shared by your team members via a Team Workspace. These are read-only but can be synced to your extension.

Pack Snippets (Lowest Priority)

Community-curated snippet packs available from the marketplace. These provide a foundation of common patterns.

When multiple snippets have the same trigger, your custom snippet takes precedence over a team snippet, which takes precedence over a pack snippet.

Categories

Snippets are organized by category to help you find what you need:

CategoryUse For
ScriptGeneral-purpose scripts
ClientClient-side scripts (UI Policies, Client Scripts, UI Actions)
ServerServer-side scripts (Business Rules, Script Includes, Scheduled Jobs)
OtherNon-script content (XML, JSON, text templates)

Contexts

Each snippet can be scoped to a specific context. When you open the quick search, only snippets matching your current context are shown:

ContextWhen It Appears
AnyAlways shown in every script field
ScriptShown in general script fields
ClientShown in client-side script fields
ServerShown in server-side script fields

This keeps the search results relevant — you won't see server-side GlideRecord snippets when editing a Client Script, and vice versa.

Cloud Sync

Your custom snippets are synced to the cloud as part of your Pro subscription. This means:

  • Cross-device access — Your snippets are available on any device where you're signed in
  • Automatic backup — Snippets are backed up to Cloud Backup
  • Team sharing — Share snippets with your team via Sharing

What's Next