A Server Script Global is a class or an object that, once defined, can be leveraged everywhere server script runs.
It is best practice to limit each Script Global to a single class or object. Expect platform to enforce this practice in the future.
Currently class an object names are not limited in any way. An upcoming release will include Class and Object names matching the Script Global's name.
We will also prevent class names that overlap existing exposed or blocked classes and functions so do not create any classes that duplicate existing classes exposed in the scripting envrionments. Doing so may result in runtime errors.
$arrayUtils, $capture, $dateTime, $dialog, $jsonUtils, $log, $original, $props, $ps, $stringUtils, $transaction, BaseFields, console, DialogResponse, document, Forms, frames, global, globalThis, NavigationType, navigator, OrderByDirection, parent, QueryOperators, screen, self, Tables, TableSecurity, ToastType, top, window,$current,BaseFields
The Development Application Menu contains an entry for Script Globals. Selecting that menu item will result in a list of exisitng Script Globals. Click the "Add" button to create a new Script Global and select "Server" as the type.

An Example Server Script Global
Name
The Name of the script global.
Application Namespace
The Application Namespace that holds the Script Global. Script globals are only accessible from within their own application. To create a "shared" script global it must be placed in the "Public" Application Namespace.
Type
Types of script where the Script Global can be called from. Server script globals can be called form all server scripts. Client script globals can be called form all client scripts.
Active
Active Script Globals can be called, inactive ones cannot.
System Managed
System Managed Script Globals ship with the base platform or as purchased application components. They are read only.
Description
Descriptive text containing any useful information developers might need in order to use the Script Global.
Script Global Tab
The Script Global tab contains the script editor associated with the type of Script Global selected in the "Type" feld.
In the Script Global section, you can define your functionality using either a JavaScript class with static members or a Plain Old JavaScript Object (POJO). Here’s a brief overview of each approach and why we recommend using one class or object per script global:
Structure and Organization: Classes provide a clear structure, encapsulating related functions (methods) and properties (variables) within a single entity.
Static Members: Static methods and properties belong to the class itself, rather than instances, making them ideal for utility functions that don’t require instantiation.
class Example {
static helloWorld() {
$ps.toast('Hello World!');
}
static anotherFunction() {
// your code here
}
}
// Usage: Example.helloWorld();
Simplicity: POJOs are simpler, ideal for grouping related functions.
const Example = {
helloWorld() {
$ps.toast('Hello World!');
},
anotherFunction() {
// your code here
}
};
// Usage: Example.helloWorld();
By defining your Script Globals as either classes with static members or plain objects, you create a robust and flexible system for reusing code, enhancing both development efficiency and application performance.
You can access classes defined by your Script Globals using the $g keyword followed by the classname.
async function serverScript($current, $original, $data, $transaction) {
// Access server globals using the $g keyword.
$g.YourClassName.yourMethodName(arguments);
}