Server-side scripts allow the system running JS scripts on the server-side when the server events happen, for example:
- writing data into the database;
- updating data in the database;
- an incoming message.
They are used to create reactions for the data writing based on the pre-defined rules (business-rules), such as:
- record saving transaction interrupting;
- associative record creation (once the record is created, one more will be created in return);
- configuration of the record creation initiated by incoming email (the incident is created upon receipt of an email) and so on.
In the server-side scripts, you can use methods that are provided by server-side API.
To define the API class in a script, you need to specify it explicitly in script code, for example:
var className = 'SimpleRecord';
If the class name is specified implicitly, then the class name need to be designated in other way, in comment as an example:
var className = 'Simple' + 'Record'; // SimpleRecord
In the case of there is a code executed through the eval() function, then adding the string below at the start of the script will import all the API classes.
// #import_all_types.
Теперь из платформы в серверные скрипты экспортируются только те классы api, которые в явном виде указаны в коде скрипта. Если какие-то классы в скрипте не указаны в явном виде. А указаны, например, вот так: var className = 'Simple' + 'Record', то необходимо в любом месте указать полное название класса например вот таким образом в комментарии: // SimpleRecord.
Если в скрипте через eval выполняется код, пришедший из какого-то источника и не известно какие классы там используются, то можно в начало скрипта добавить строчку // #import_all_types. В этом случае с платформы будут экспортированы все классы.
The subsections of this section will give more details and specifics of server-side scripts usage.