gliderecord-patterns

Query and manage ServiceNow records with GlideRecord best practices.

77|23|Updated Jul 16, 2025
One-click install
npx skills add https://github.com/serac-labs/serac --skill gliderecord-patterns-serac-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gliderecord-patterns
Source: https://github.com/serac-labs/serac/tree/main/packages/opencode/src/bundled-skills/gliderecord-patterns
Command: npx skills add https://github.com/serac-labs/serac --skill gliderecord-patterns-serac-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

GlideRecord is the primary API for database operations in ServiceNow. Following these patterns helps engineers write efficient, safe queries and CRUD operations, reducing errors and performance issues.

Core Features & Use Cases

  • Get Single Record by sys_id or field value to retrieve precise records quickly.
  • Query Multiple Records efficiently using addQuery, orderByDesc, and setLimit; avoid N+1 queries with batch retrieval.
  • Use Encoded Queries and GlideAggregate for faster, scalable data access; provide examples for counts and aggregates.
  • Robust CRUD guidance for insert, update, and delete operations across common tables like incident, task, and user.

Quick Start

Fetch the first 10 active incidents and print their numbers using GlideRecord.

Frequently Asked Questions about gliderecord-patterns

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

FAQPage Schema
How do I query ServiceNow records safely without causing performance issues?

To query ServiceNow records safely, use GlideRecord best practices like retrieving single records by sys_id, applying setLimit to cap results, and using encoded queries to prevent oversized data retrieval and performance degradation.

What is the best way to retrieve a single ServiceNow record using GlideRecord?

The best way to retrieve a single ServiceNow record is by looking up its sys_id directly, which is precise and efficient. You can also query by a specific field value to quickly fetch the exact record needed.

Can I use GlideAggregate instead of GlideRecord for counting records?

Yes, you can use GlideAggregate instead of standard GlideRecord queries for faster, scalable data access. GlideAggregate is specifically recommended for performing counts and aggregate functions across ServiceNow tables.

How do I perform bulk queries across the incident and task tables in ServiceNow?

For bulk queries across incident and task tables, use GlideRecord with addQuery and orderByDesc. Apply setLimit to restrict the result set and avoid N+1 queries by retrieving records in batches for better performance.

What are the limitations of using GlideRecord for CRUD operations in ServiceNow?

GlideRecord limitations include potential performance bottlenecks with oversized results and N+1 query patterns. You must enforce proper error handling, apply setLimit, and use encoded queries to ensure safe insert, update, and delete operations.