Several global constants are available at runtime in a script.

Context

The main global constant is the Context object, the contents of which depend on the location of the script. For process scripts, Context contains information about an instance of that process. Context is an object with a list of user-defined fields (read more Object Types). For example, if you add a field of string type and the code foo to the Context tab, you will be able to interact with in the following way:

Context.data.foo = 'some  string';

Context is much like an application element, except that it has no save or delete methods. It is saved automatically at the end of a
script.

Application

If the process is inside an app, the Application object is always available, providing methods to work with the current app. For example, you can create a new order

const order = Application.create();
order.data.client =  Context.data.client; 
await order.save(); 

Namespace

If the process belongs to a workspace, it can have the Namespace object available containing all the apps in that workspace. Thus a description of a particular app can be obtained as Namespace.app.orders

const clientOrders = await Namespace.app.orders.search()
    .where(f =>  f.client.eq(Context.data.client)) 
    .all(); 

Global

The script may also contain the Global object with a description of
all workspaces. Using this object prevents further export of the script, i.e., if you use this object in a process script in a workspace or an app, that workspace or app will not be available for export. The Global object contains all available workspaces in the ns field, that is, if you create a store workspace with an orders app, then its description can be obtained as Global.ns.store.app.orders.

const clientOrders = await  Global.ns.store.app.orders.search()
    .where(f =>  f.client.eq(Context.data.client)) 
    .all(); 

Read more about working with app in Working with apps. The Global constant is always available in company processes. Workspace and app processes
must be able to access this constant.

Launching processes

It is also possible to launch processes from Namespace and Application objects.

await Application.processes.process_code.run({param: 1});
await Namespace.processes.process_code.run({param: 1}); 
await  Global.ns._clients.app._leads.processes.process_code.run({param: 1}); 
await  Global.ns._clients.processes.process_code.run({param: 1}); 

For details see description of the Process.

System

In the System object, such system collections as users, user groups, organizational chart and others are available.

Server

In the widget client scripts the global constant Server is available. In the Server object, the methods from the widget's server script can be called.

await  Server.rpc.doSomething()