GlideElement

GlideElement provides methods for dealing with the fields in a GlideRecord object. This class is one of the smaller ones in ServiceNow.

One very handy set of methods in this class is detecting changes to a field. This is very helpful in closing down records. Sometimes we may want to run some script on closure of the record, but not every time the record is updated. This is when the changesTo method can be used. We'll assume we are using an incident, in this case where the closed state is 7:

if  (current.state.changesTo('7')) {    //Run some closure script}

This preceding example will allow for some script to run when the record is closed, but only when it moves to being closed. If the closed record is subsequently updated, then this ...

Get Mastering ServiceNow Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.