- Home [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
- Getting started
- Manage types
- Global context and isolation
- Manage apps
- Work with external services
- Scripts in widgets
- Web components
- Access permissions
- Getting started with processes
- Getting started with signatures
- Getting started with file previews
- Getting started with the organizational chart
- Getting started with users and groups
-
Getting started with the
Table data type - Use cases
- How to set up custom view of app items
- How to set up dynamic display of fields and widgets with a complex condition
- How to register a document
- How to calculate the number of days between two dates
- How to create a substitution for a user
- How to use pagination and sorting when searching for app items
- API
- Object types
- Data types
- Global constants
- Work with apps
- Web requests
- Access permissions
- Document flow
- Live Chats
- “Code” widget
- Signatures
- Business calendars
- Integration with IP telephony
- Integration with email marketing services
In this article
Global context and isolation
During a script’s execution, several global constants can be called.
Context
The main global constant is the
Context
object. Its content depends on the location of the script. For example, in a process script,Context
contains information about the instance of this process.Context
is an object with a list fields determined by the user (read more in Manage types). For example, if you add a String type field with the codefoo
to the Context tab, you’ll be able to work with it in the following way:Context.data.foo = 'some string';
Context
is much like an app item object, except that it has no methods for saving or deletion. It is saved automatically when the script finishes executing.Application
If a process or widget is associated with an app, the Application object can always be accessed in it. This global constant provides methods to work with the current app. For instance, you can create a new order in the following way:
const order = Application.create(); order.data.client = Context.data.client; await order.save();
Namespace
If a process or widget is associated with a workspace, it may have access to the
Namespace
object that contains all apps stored in the workspace. This allows you to get the description of a specific app, for example,Namespace.app.orders
:const clientOrders = await Namespace.app.orders.search() .where(f => f.client.eq(Context.data.client)) .all();
Global
You can also call the
Global
object in your scripts. It contains the description of all workspaces. If you use this object, the export of the script will be forbidden. This means that if you useGlobal
in a script of a process or a widget associated with a workspace or an app, you won’t be able to export this workspace or app.The
Global
object contains all available workspaces in thens
field. This means that if you create thestore
workspace and theorders
app inside of it, you can get the app’s description usingGlobal.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 apps in the Manage apps article. The
Global
constant is always available in global processes and widgets. In processes associated with apps or workspaces, you need to manually allow access to this constant.Starting processes
You can also use the
Namespace
andApplication
objects to start processes.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 more information, see the description of the Process object.
System
Using the System object, you can access such system collections as:
System.users (users)
System.userGroups (user groups)
System.organisationStructure (organizational chart)
System.files (files)
System.replacements (substitutions)
System.productionSchedule (business calendar)
System.processes (system processes)
System.timezones (time zones)
System.cache (cache to temporary store data on the server)
System.storage (long-term storage to store arbitrary data on the server)
System.mailbox (work in the Email workspace)
Server
In client-side widget scripts, the
Server
global constant can be called. In theServer
object, methods from the widget’s server-side scripts are available.await Server.rpc.doSomething()
Read more in the Scripts in widgets article in the Help Center.