Using GlideRecord (and its friends)
The previous two chapters demonstrated that ServiceNow is built around data. Background scripts, and scripts in general, can use the excellent database connectivity capabilities built into ServiceNow to easily access whatever information we want. GlideRecord
is instrumental in doing this.
GlideRecord
is a class that lets you work with a database table. With it, you can create, read, or update records in a database. In general, you work one record at a time, iterating through a result set.
It is easy to use, but I recommend reviewing the basics from the product documentation or a scripting course. In this chapter, we'll quickly run through the basics and start to explore the gotchas as well as some very interesting features that are misunderstood.
Tip
For full details, investigate the documentation at https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&type=server&scoped=true&to=class__scoped_gliderecord__helsinki
.
Let's run some...