Creating Snippets
How to create, edit, organize, and manage your custom code snippets.
Last updated: February 19, 2026
Last updated: February 19, 2026
Custom snippets are code templates you create for patterns you use often. They live in your SN Utils account, sync across devices, and can be shared with your team.
/newsnip)The fastest keyboard path from any ServiceNow page: type /newsnip in the slash palette to jump straight to the Snippets tab with a blank editor ready and the prefix field focused.
Add a description after the shortcut to seed the editor:
/newsnip — open blank editor, just author./newsnip GlideAggregate counting incidents by category — description prefilled. On Pro the AI Assistant runs the prompt and fills in name, prefix, category, context, and body; on Community the description is prefilled into the editor so you have a starting point for writing the snippet yourself.Open the AI side panel from the Snippets tab on the Manage page and describe what you need in plain language — for example, "create a GlideAggregate snippet that counts incidents by category". The AI generates a complete snippet with a name, prefix, category, context, and working code — ready to save and use immediately. The same AI Builder is what /newsnip <description> opens for you in one keystroke from anywhere in ServiceNow.
/manage)The quickest way to capture code you've just written is to right-click your selection inside any ServiceNow script field (Business Rule, Script Include, Client Script, UI Script, Background Script, the SN Utils Code Editor, …) and pick Save selection as snippet… from the Monaco context menu.
The Manage page opens straight to the Snippets tab with the body editor already pre-filled with your selection — type a prefix and a name, then hit Save. No copy/paste round-trip and no scrolling to the bottom of the editor pane.
Tip: works on any selection, single-line or multi-line, including formatted indentation.
| Field | Required | Description |
|---|---|---|
| Name | Yes | A short, descriptive name (shown in search results) |
| Prefix | No | A shorthand trigger (e.g., gr for GlideRecord). If set, typing the prefix filters results faster |
| Category | Yes | Script, Client, Server, or Other |
| Context | Yes | Where the snippet appears: Any, Script, Client, or Server |
| Description | No | A brief explanation of what the snippet does. Shown below the name in search results |
| Code | Yes | The actual code template to insert |
Use descriptive placeholder text that guides the user on what to replace:
var gr = new GlideRecord('TABLE_NAME');
gr.addQuery('FIELD', 'VALUE');
gr.query();
while (gr.next()) {
// your code here
}
Snippets preserve formatting and indentation. Write your snippet exactly as you want it inserted:
(function() {
var ga = new GlideAjax('YOUR_SCRIPT_INCLUDE');
ga.addParam('sysparm_name', 'YOUR_METHOD');
ga.addParam('sysparm_value', VALUE);
ga.getXMLAnswer(function(response) {
var result = JSON.parse(response);
// handle result
});
})();
Short snippets work great for common expressions:
gs.getUser().getID()
Pick the right category so your snippets appear in the right context:
The quick search matches against both the name and the prefix. Choose names that describe the pattern:
Set a short prefix for your most-used snippets. When you type in the quick search, prefix matches appear first:
| Prefix | Snippet |
|---|---|
gr | GlideRecord basic query |
gre | GlideRecord with encoded query |
ga | GlideAjax call |
rest | RESTMessageV2 outbound |
log | gs.info with formatted message |
From the website or the Manage page, find the snippet and click to open it. Make your changes and save.
Open the snippet and click Delete. If the snippet is shared with your team, deleting it removes it from everyone's sync.
You can share snippets with your team through the Sharing feature:
Team members can then browse and sync your shared snippets.
You can include {{variables}} in your snippet code to create dynamic templates. When the snippet is used in clipboard mode (outside an editor), variables are resolved with live data from the current record and your user profile.
For example, a greeting snippet:
Hi {{caller_id.first_name}},
Kind regards,
{{$first_name}}
See Snippet Variables for the full syntax and examples.
{{variables}} with live data