askill
servicenow-manipulate-data

servicenow-manipulate-dataSafety 85Repository

Query, insert, update, and delete records in the ServiceNow database with emphasis on performance and security. Covers GlideRecord, GlideQuery, GlideAggregate, and secure data access patterns. Use when working with database records, aggregating data, or implementing data-driven logic.

3 stars
1.2k downloads
Updated 2/21/2026

Package Files

Loading files...
SKILL.md

Manipulate ServiceNow Data

Quick start

Querying records (traditional):

var gr = new GlideRecord('incident');
gr.addQuery('state', 'Open');
gr.addQuery('priority', '<=', 2);
gr.orderBy('created_on');
gr.query();

while (gr.next()) {
    gs.info('Incident: ' + gr.getValue('number'));
}

Modern fluent queries:

var records = new global.GlideQuery('incident')
    .where('active', true)
    .where('priority', '<=', 2)
    .select();

for (var i = 0; i < records.length; i++) {
    var incident = records[i];
}

Aggregating data:

var agg = new GlideAggregate('incident');
agg.addAggregate('COUNT');
agg.addAggregate('SUM', 'time_worked');
agg.query();

while (agg.next()) {
    var count = agg.getAggregate('COUNT');
    var total = agg.getAggregate('SUM');
}

Secure access (with ACL enforcement):

var gr = new GlideRecordSecure('confidential_table');
gr.query();
// Only returns records user has permission to see

Performance patterns

PatternUse CasePerformance
setLimit(1)Existence checkFast
getValue('field')Get single valueNo dot-walk overhead
GlideAggregateCount/SumMuch faster than loop
addEncodedQuery()Complex filtersCopy from list view

Best practices

  • Use GlideQuery for new code (modern, fluent)
  • Use GlideRecord for complex queries and CRUD operations
  • Never iterate to count; use GlideAggregate instead
  • Use getValue() instead of dot-walking for performance
  • Use GlideRecordSecure when ACLs matter
  • Use setLimit(1) for existence checks
  • Copy encodedQuery from list views for complex filters
  • Test queries on sub-production before production
  • Refactor repeated query logic into Script Includes
  • Always check if record exists with next() before accessing

Key APIs

APIPurpose
GlideRecordCRUD operations, traditional
GlideQueryNEW - fluent, modern queries
GlideAggregateCounts, sums, aggregations
GlideRecordSecureACL-enforced queries
GlideFilterAdvanced filtering operations

Reference

For Performance optimization, decision matrices, and anti-patterns, see BEST_PRACTICES.md

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

79/100Analyzed 2/22/2026

High-quality technical reference skill for ServiceNow data manipulation. Covers GlideRecord, GlideQuery, GlideAggregate, and secure access patterns with practical code examples. Well-structured with performance patterns table, best practices, and API reference. Includes modern fluent approach (GlideQuery) alongside traditional methods. Score benefits from clear 'when to use' description, structured actionable content, relevant tags, proper skills folder location, and high-density technical accuracy. Minor gaps include CRUD operation details and error handling. Highly reusable for any ServiceNow developer."

85
82
80
68
78

Metadata

Licenseunknown
Version-
Updated2/21/2026
PublisherDanielMadsenDK

Tags

apitesting