servicenow-gliderecord

Enforce GlideRecord best practices for ServiceNow server-side scripting.

Updated Mar 24, 2026
One-click install
npx skills add https://github.com/Xerrion/servicenow-opencode-config --skill servicenow-gliderecord
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: servicenow-gliderecord
Source: https://github.com/Xerrion/servicenow-opencode-config/tree/main/skills/servicenow-gliderecord
Command: npx skills add https://github.com/Xerrion/servicenow-opencode-config --skill servicenow-gliderecord

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

GlideRecord and GlideAggregate are core to ServiceNow server-side scripting, but improper usage causes performance problems and fragile code. This guide defines best practices to ensure safe, efficient data access and manipulation.

Core Features & Use Cases

  • Enforces getValue and setValue for all reads/writes to maintain type safety.
  • Requires query() before iterating with next() and discourages nested queries inside loops.
  • Prefers GlideAggregate for counting and aggregation over manual record iteration.
  • Provides practical patterns for existence checks, null handling, and update/insert/delete operations.
  • Real-world scenarios include bulk reads of incidents, aggregation by priority, and safe updates with minimized data loads.

Quick Start

Write a minimal GlideRecord script that queries active incidents, reads a field with getValue, and updates priority with setValue.

Frequently Asked Questions about servicenow-gliderecord

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the best way to query ServiceNow records using GlideRecord?

The best way to query ServiceNow records with GlideRecord is to call query() before iterating with next(), use getValue for reads, and avoid nested queries inside loops to ensure efficient server-side data access.

How do I use GlideAggregate for counting records in ServiceNow?

Use GlideAggregate for counting and aggregating records in ServiceNow instead of manually iterating with GlideRecord. This approach enforces best practices by minimizing data loads and improving server-side performance during bulk operations.

Should I use getValue and setValue for GlideRecord field access?

Yes, you should use getValue and setValue for all GlideRecord field reads and writes. This practice maintains type safety and prevents fragile code when manipulating ServiceNow records during server-side scripting tasks.

How do I safely update ServiceNow records without causing performance issues?

To safely update ServiceNow records, apply safe update patterns by checking record existence, handling nulls properly, and minimizing data loads. Preferring GlideAggregate for aggregation prevents performance bottlenecks.

Why does my GlideRecord loop return undefined values in ServiceNow?

GlideRecord loops return undefined values when query() is not called before next(), or when direct field access is used instead of getValue. Enforcing query execution first and using getValue ensures accurate data retrieval.

Can I use GlideRecord for bulk aggregation tasks in ServiceNow?

You can use GlideRecord for bulk tasks, but GlideAggregate is strongly preferred for aggregation and counting in ServiceNow. GlideAggregate bypasses manual record iteration, delivering optimized and safe performance for large data sets.