Using Snippets

How to search, preview, and insert code snippets into ServiceNow script fields.

Once you have snippets (your own, team-shared, or from packs), inserting them into any script field takes just a few keystrokes.

The Quick Search Popup

Opening It

Press ⇧⇧ (Shift twice quickly) while your cursor is in any script field. The snippet quick search popup appears as an overlay.

Snippet quick search popup over a ServiceNow script field

The popup works in:

  • Classic form script fields
  • Next Experience / Workspace script editors
  • The full-screen Monaco editor
  • Service Portal widget editors (via ScriptSync)

Searching

Start typing to filter snippets by:

  • Name — Matches against the snippet name
  • Prefix — Matches against the snippet prefix (prefix matches appear first)
  • Description — Matches against the snippet description

Results update as you type. The most relevant matches appear at the top.

Context Filtering

The quick search automatically filters snippets based on your current editing context:

  • Editing a Client Script? Only snippets with Client or Any context appear
  • Editing a Business Rule? Only snippets with Server or Any context appear
  • In a general script field? All snippets appear

This keeps results relevant without manual filtering.

Previewing

Hover over or arrow-key to a snippet to see a preview of its code. This helps you confirm you're selecting the right snippet before inserting.

Snippet preview showing code content before insertion

Inserting

Press Enter or click on a snippet to insert it at your cursor position. The popup closes and the code appears in your editor.

The snippet is inserted with proper indentation, matching the indentation level of your cursor.

Priority Order

When multiple snippets match your search, they follow this priority:

  1. Custom snippets (your own) — Highest priority
  2. Team snippets (shared by teammates) — Medium priority
  3. Pack snippets (community packs) — Lowest priority

If a custom snippet and a pack snippet have the same prefix, the custom one wins.

Keyboard Shortcuts Summary

ShortcutAction
⇧⇧ (double Shift)Open/close the quick search popup
TypeFilter snippets
↑ / ↓Navigate results
EnterInsert selected snippet
EscapeClose popup without inserting

Clipboard Mode

When you open the snippet popup outside a script field or text area (e.g., while viewing a form without focus in an editable field), the popup switches to clipboard mode. Instead of inserting, pressing Enter copies the snippet to your clipboard.

Snippet popup in clipboard mode showing the clipboard badge and Copy label <!-- Screenshot needed: Snippet popup in clipboard mode with "clipboard" badge visible in header and "Copy" in footer -->

In clipboard mode, any {{variables}} in the snippet are resolved with live data before copying. This is useful for preparing personalized text (greetings, status updates, work notes) that you can paste anywhere.

Look for the clipboard badge in the popup header and the Copy label in the footer to know you're in clipboard mode.

Learn more about Snippet Variables →

Tips

  • Build muscle memory — Assign short prefixes to your top 5-10 snippets and practice typing them. Within a few days, you'll insert common patterns faster than copy-paste.
  • Check the context — If a snippet doesn't appear, check its context setting. A server-only snippet won't show in a Client Script field.
  • Use with Monaco — The quick search works with the SN Utils full-screen Monaco editor too. Open Monaco with the code editor button, then press ⇧⇧ inside it.
  • Use variables for templates — Add {{caller_id.first_name}} or {{$name}} to create snippets that auto-fill with live data when copied. See Snippet Variables.