Creating Snippets
How to create, edit, organize, and manage your custom code snippets.
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.
Creating a New Snippet
With the AI Assistant
The fastest way to create a snippet is with the AI Assistant. Open the AI side panel 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.
From the Manage Page
- Open the Manage page (click the gear icon in the popup header, or use
/manage) - Go to the Snippets tab
- Click the + button
- Fill in the snippet details
- Click Save

Snippet Fields
| 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 |
Writing Effective Snippet Code
Placeholders
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
}
Multi-line Snippets
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
});
})();
Single-line Snippets
Short snippets work great for common expressions:
gs.getUser().getID()
Organizing Snippets
Use Categories Consistently
Pick the right category so your snippets appear in the right context:
- Client for anything that runs in the browser (Client Scripts, UI Policies, UI Actions with client=true)
- Server for anything that runs on the server (Business Rules, Script Includes, Scheduled Jobs)
- Script for patterns that work in both contexts
- Other for non-JavaScript content (XML, JSON, emails)
Name for Searchability
The quick search matches against both the name and the prefix. Choose names that describe the pattern:
- "GlideRecord query with encoded query" instead of "gr query"
- "REST message outbound POST" instead of "rest"
- "Client Script onChange template" instead of "onChange"
Use Prefixes for Speed
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 |
Editing and Deleting
Edit a Snippet
From the website or the Manage page, find the snippet and click to open it. Make your changes and save.
Delete a Snippet
Open the snippet and click Delete. If the snippet is shared with your team, deleting it removes it from everyone's sync.
Sharing Snippets
You can share snippets with your team through the Sharing feature:
- Edit a snippet
- Set the Sharing level to Team or All Teams
- Save
Team members can then browse and sync your shared snippets.
Using Variables in 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.
Related
- Using Snippets — Keyboard shortcuts and insertion
- Snippet Variables — Dynamic
{{variables}}with live data - Code Snippets Overview — Categories, contexts, and priority
- Sharing Resources — Share with your team