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

  1. Open the Manage page (click the gear icon in the popup header, or use /manage)
  2. Go to the Snippets tab
  3. Click the + button
  4. Fill in the snippet details
  5. Click Save

Creating a new snippet from the Manage page

Snippet Fields

FieldRequiredDescription
NameYesA short, descriptive name (shown in search results)
PrefixNoA shorthand trigger (e.g., gr for GlideRecord). If set, typing the prefix filters results faster
CategoryYesScript, Client, Server, or Other
ContextYesWhere the snippet appears: Any, Script, Client, or Server
DescriptionNoA brief explanation of what the snippet does. Shown below the name in search results
CodeYesThe 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:

PrefixSnippet
grGlideRecord basic query
greGlideRecord with encoded query
gaGlideAjax call
restRESTMessageV2 outbound
loggs.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:

  1. Edit a snippet
  2. Set the Sharing level to Team or All Teams
  3. 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.