Using ServiceNow exposed JavaScript APIs
ServiceNow provides developers with some exposed JavaScript APIs to aid them with the scripts they write. This saves a lot of time in accessing records and fields in scripts in ServiceNow. There are a number of different classes and objects available to developers, some of which very helpful and others rarely used.
GlideRecord
One of the most common JavaScript APIs is the GlideRecord
class, which is extremely handy and will fast become a staple of most scripting. GlideRecord
is a way of finding and counting records in ServiceNow based on many different queries. It is quite similar to a SQL statement if that is something you are familiar with.
Let's have a look at how to use GlideRecord
.
We'll take a look at how to query all the records in a particular table. The format of the GlideRecord
script for this is shown in the following, with table_name
being the only parameter. This needs to be the table name rather than the table label:
new GlideRecord('<...