← Home
🔥0 DAY
0 XP

GlideRecord

GlideRecord is the server-side ServiceNow API for querying, inserting, updating and deleting records, walking results row by row through query() and next().

Also searched as: GlideRecord query, server-side query API.

In practice

Use addQuery for conditions, addEncodedQuery for filters copied from a list, and setLimit when you only need a few rows. For counts and sums use GlideAggregate instead — it pushes the maths to the database rather than pulling rows into memory. Never nest a query inside a result loop.

Example

Fetch every active P1 incident for a group and update its work notes in one pass.

var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.addQuery('priority', 1);
gr.query();
while (gr.next()) {
  gr.work_notes = 'Escalation review';
  gr.update();
}

What interviewers check

Expect GlideRecord vs GlideAggregate, and whether you spot the N+1 query antipattern in sample code.

Practise this topic

Related Automation terms