With creation or deletion of an object of some class, the system is able to execute scripts and pass to them arguments which are set via the web interface.
Any script consists of two files:
- the executable file,
- the configuration file, which describes the web interface of the Triggers tab for passing arguments to the executable file.
The configuration file must:
- be placed to the folder with the executable file;
- have the name of the executable file with the additional extension .conf
The executable files of the scripts can be grouped in subfolders with any number of sublevels:
When adding or modifying configurations, the changes are applied with refreshing the page in a web browser.
Folder for scripts
Triggers folder is set in the server configuration file .
It is necessary to:
- Add the custom_scripts section into the file.
Set the full path to the folder where the scripts are stored in the parameter entity_triggers_path:
Restart the server:
Parameters of the scripts
Script parameters are set in the JSON file named as executable_file_name.conf. For instance, if the executable file is named as myScript.sh, then the configuration file must be named as myScript.sh.conf.
The configuration file must be placed into the same folder as the executable file.
Scripts without the configuration files are ignored.
The configuration file can contain the following fields:
Script name which is displayed in the web interface in the lists of scripts.
By default it is the identifier, generated from the path and the name of the script:
|args||The array of the arguments, which are set by users in the web interface and passed to the executable file.|
Argument name, which is passed to the executable file.
The default value of the argument, which is entered into the corresponding field.
Description of the argument, which is displayed in the web interface.
Argument name, which is displayed in the web interface.
Applicable only for the select type (args.type.select).
Defines the list of argument values, which are displayed in the web interface.
The following is passed to the executable file:
This logic can be used to implement the "Not selected" option and delimiters in the dropdown list.
Description of the argument value, which is displayed in the web interface.
By default the argument value (args.options.value) is displayed.
If this field is not set, then the argument name is not passed to the executable file. These options can be used in order to implement the "Not selected" option and delimiters in the dropdown list.
Indicates if the argument value is required.
By default false.
Type of the argument value.
By default | text.
By default it is disabled.
When it is enabled, the value of the args.id field (argument name) is passed to the executable file. If the field is not set, then the index number of the argument is passed to the executable file (starting from 0).
|args.type.password||The text field with masking of input characters.|
|args.type.text||Text field to enter argument value.|
Text field to enter argument value.
Allows to enter multiline text.
To demonstrate the script functionality and different argument types we have prepared two files.
- Place the files to the script folder.
- Set execution of the script "Custom script example" with creation or deletion an object of any class in the Triggers tab.
- Set argument values.
- Create or delete an object of the selected class.
The executable file of the script records all of the passed arguments to the output file:
This configuration file contains examples for all argument types: