ServiceNow Cheat Sheets · LessonBy Praveen T, ServiceNow Trainer, 9 yrs · Published · current release · reference
GlideRecord cheat sheet
Every GlideRecord pattern on one page.
Quick answer
Bookmark this. Run any snippet in the editor below.
Key takeaways
- Query
- Iterate
- CRUD
Bookmark this. Run any snippet in the editor below.
Query
var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.addQuery('priority', '<=', 2);
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();Iterate
while (gr.next()) {
gs.info(gr.number + ' ' + gr.getValue('short_description'));
}CRUD
gr.initialize();
gr.setValue('short_description', 'New');
var id = gr.insert();
// gr.update(); gr.deleteRecord();Try it YourselfJavaScript
▸ Press Run to execute.
Runs in a sandbox in your browser. Mock gs and GlideRecord and sample data are provided.
Quick check
+0 XPStreak ×0
Question 1 of 2
Which sorts newest first?
Frequently asked questions
What does the term GlideRecord cheat sheet refer to in ServiceNow?
Bookmark this. Run any snippet in the editor below.
Practise this on your own free instance.