
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 08:34 AM
Dear experts,
Can someone help me with a reference which lists ALL the GLOBAL VARIABLES AND OBJECTS that can be used in Now platform while scripting? Also with documentation where they can be used - on Business Rules, Client Scripts, .....
Hope you got my question?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- 8,927 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 12:29 PM
You can easy see the type of entries and even see the code of most functions. Try the following code in Background Script
var props = Object.keys(this), functions = [], variables = [], unknowns = [], unaccessibles = [];
props.forEach(function (prop) {
try {
var type = typeof this[prop];
//gs.print("typeof " + prop + "=" + type);
switch (type) {
case "function":
functions.push(prop);
break;
case "object":
if (prop !== "props" && prop !== "functions" && prop !== "variables" && prop !== "unknowns" && prop !== "unaccessibles") {
variables.push(prop);
}
break;
default:
unknowns.push(prop);
gs.print("typeof " + prop + "=" + type);
break;
}
} catch (ex) {
unaccessibles.push(prop);
}
});
gs.print("variables=" + variables);
gs.print("functions=" + functions);
gs.print("unknowns=" + unknowns);
gs.print("unaccessibles=" + unaccessibles);
functions.forEach(function (prop) {
try {
gs.print(this[prop]);
} catch (ex) {}
});
You will see variables sys_meta,system,gs,Class,global,current,previous, which are objects, variable "glide.security.is.admin" of boolean type and the string variable __script. You can add gs.print("glide.security.is.admin=" + this["glide.security.is.admin"]); and gs.print("__script=" + this[__script]); to see the values of the variables. Later you will see the code of many global functions, which are defined mostly in Script Include or Business Rules of the type Global.
As I wrote before, the most of information has no practical usage, but it could be interesting for common understanding.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 08:46 AM
Hello Anish,
Global variables in business rules
Use the following predefined global variables to reference the system in a business rule script.
1. current :The current state of the record being referenced. Check for null before using this variable.
2. previous: The state of the referenced record prior to any updates made during the execution context, where the execution context begins with the first update or delete operation and ends after the script and any referenced business rules are executed. If multiple updates are made to the record within one execution context, previous will continue to hold the state of the record before the first update or delete operation. Available on update and delete operations only. Not available on asynch operations. Check for null before using this variable.
3. g_scratchpad: The scratchpad object is available on display rules, and is used to pass information to the client to be accessed from client scripts.
4. gs: References to GlideSystem functions.
The variables current, previous, and g_scratchpad are global across all business rules that run for a transaction.
Widget Global Objects and Functions:
Following are the some of the ServiceNow Server Side Glide classes:
- GlideRecord: This class is used for database operations instead of writing SQL queries.
- GlideElement: This class is used to operate on the fields of the current GlideRecord.
- GlideSystem: This class is used to get information about the system
- Glide Aggregate: This class is used to perform database aggregation queries
- GllideDateTime: This classes is used to perform date-time operations
Following are the some of the ServiceNow Client Side Glide classes:
- GlideAjax: This class is used to execute server-side code from the client
- GlideDialogWindow: This class is used to display a dialog window
- GlideForm: This class is used to customize forms
- GlideList2: This class is used to customize (v2) lists, including normal lists and related lists
- GlideMenu: This class is used to customize UI Context Menu items
- GlideUser: This class is used to get session information about the current user and current user roles
https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=no-namespace
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 09:23 AM
Hello Anish,
Can please mark as Correct Answer if your queries are resolved? if not, let us know what else you want to know.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 08:56 AM
It's native question, which ask the most developers. It's clear, that the list of global variables depend on context: UI Actions, Business Rules, Notification script, script inside of Workflow, Server Script of widget and so on - all have different list of global variables.
You can try to use standard JavaScript trick to get variables. The only problem is - the name of global variable is different in different context. Mostly this, global or window are the current global object. So you can use something like
gs.info(Object.keys(this));
or
gs.print(Object.keys(global));
On the other side, knowledge of global names helps not really if the meaning is unknown of the variable isn't documented. If the value exist in your environment in the current version then it's unsafe to use it because the variable can not exist in new version or new environment.
In any way it would be very good if the official ServiceNow side clear describes all supported global variables in the corresponding context including of corresponding methods and properties.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 10:34 AM
Hey thanks Oleg!
I got the list with this help.
There are 134 entries I could find in response. But all of them do not seem to be variables.