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.
<!-- Screenshot needed: Snippet quick search popup over a script field with a few results -->
Quick Start
- Press ⇧⇧ (Shift twice quickly) while your cursor is in a script field
- Type a few characters to search
- Select a snippet from the results
- 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:
| Category | Use For |
|---|---|
| Script | General-purpose scripts |
| Client | Client-side scripts (UI Policies, Client Scripts, UI Actions) |
| Server | Server-side scripts (Business Rules, Script Includes, Scheduled Jobs) |
| Other | Non-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:
| Context | When It Appears |
|---|---|
| Any | Always shown in every script field |
| Script | Shown in general script fields |
| Client | Shown in client-side script fields |
| Server | Shown 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
- Creating Snippets — How to create and manage your own snippets
- Using Snippets — Keyboard shortcuts, search, and insertion
- Snippet Variables — Use
{{variables}}for dynamic content with live data
Related
- Sharing Resources — Share snippets with your team
- Backup & Sync — How cloud sync works
- Free vs Pro — Compare plans