IT CanvassTalk to an advisor
ServiceNow References · LessonReviewed by Neelima, ServiceNow Architect · Updated · Published · current release · reference

ServiceNow GlideRecord API

The essential server-side query methods.

Quick answer

GlideRecord is the server-side API for reading and writing ServiceNow tables. Build a query with addQuery, addActiveQuery or addEncodedQuery, order and limit it with orderBy and setLimit, run query() and step through rows with next(). On each row, getValue and setValue read and write fields, insert, update and deleteRecord persist the change, and get(sys_id) fetches one record directly.

Key takeaways
  • Query
  • Read & write

GlideRecord is the server-side database API.

Query

  • addQuery(field, value), add a condition.
  • addActiveQuery(), active = true.
  • addEncodedQuery(str), a full encoded query.
  • orderBy(field) / setLimit(n)
  • query() then next()

Read & write

  • getValue(field) / setValue(field, val)
  • insert() / update() / deleteRecord()
  • get(sys_id), fetch one record.
  • getRowCount()
Try it YourselfJavaScript
▸ Press Run to execute.

Runs in a sandbox in your browser. Mock gs and GlideRecord and sample data are provided.

Practise this on your own free instance.
Set up your free instance →
Already working on ServiceNow and stuck on a live ticket?Get an expert ServiceNow developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support