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()thennext()
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.