GlideSystem

GlideSystem is probably the most commonly used server-side classes. Let's have a look at how we can utilize this class to aid us in our scripting.

ServiceNow shortens GlideSystem to gs in scripts so the methods of GlideSystem will be prefixed with gs.

Let's start by seeing how to get a user's sys_id using GlideSystem:

var userID = gs.getUserID();

This puts the logged-in user's sys_id in the userID variable. This can be helpful as you can use this in scripts where you may want to execute different lines of script depending on the attributes of the user. Now we have the user's sys_id, we could use a GlideRecord query to return the fields we desire. ServiceNow does allow us to obtain some of this information in an easier way.

We ...

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.