Administrators can add custom features to their libraries by using custom scripts. To create a new custom script, open the library administration interface and click on custom scripts (1).
You can create a new script by clicking “Add new value” (2), rename existing script (3), select the type of the custom script (4) or delete a custom script (5). The following script types are available:
- Backend Action, executed by workflow transitions.
Learn more here: Configure Workflow custom actions
- Viewer Action, custom actions that can be executed by clicking on a link in the "more actions" menu of the document viewer.
Learn more here: Configure document classes custom actions
- Update Action, custom scripts executed when a document is created or updated.
- Relation Filter, custom scripts used to filter the list of documents displayed in the "related documents" section of the document properties.
- Relation Render Action, custom scripts used to customized the way related documents are displayed in the "related documents" section of the document properties.
Custom script window
Click on the name of a custom script to configure it (6). In the configuration section you can edit the name and type of script (7)
Note: that changing the type of an existing script will reset the content of the script to the default value, so any existing script code will be lost.
You can also make the execution of the script asynchronous (8) for backend actions and update actions only. When "async execution" is checked, the script is not executed immediately, but on the other hand it has more time to be completed (~10 minutes instead of ~1 minute).
Important: When a script is asynchronous the script won’t be able to modify the properties of documents (an error will occur when the script tries to lock the document for writing).
Editing the script name, type and async execution mode
The security mode list box (9) lets you configure the permissions that your script will have when running:
- If "run with the current user’s privileges” is selected, the script will be executed with the privileges of the current user (the one that has triggered the execution of the script). In this case, if the script tries to access a document on which the current user has no permission, the script will fail with a permission denied error;
- If "run with the current administrator’s privileges" is selected, the script will have administrator access, i.e. it will be able to access all documents. This needs to be used carefully because such scripts can lead to a security breach (for example an administrator script could be used by a user to gain access to documents that he or she has no permission to access).
Setting the security mode for custom scripts
The “Imports” section (10) lets you configure the list of classes that you want your script to import. The code editor (11) lets you configure the source code of your script. Depending on the type of script you are editing, you can edit the source code of different methods (use the list box (13) to select the method you want to edit):
- _execute, to execute Backend Action and Viewer Action scripts
- _isApplicable, to configure who can start the execution of a Viewer Action script
- _getDisplayName, to return the name of a Viewer Action script defined in the document class
- _executeAsync, to execute a Viewer Action script when the execution is set to be asynchronous _filter, to execute Relation Filter scripts
- _update, to execute Update Action scripts
- _createRelationVO, to execute Relation Render Action scripts
In the parameters section of the custom script page you can configure parameters for your script, and define the default value for each parameter (12). When configuring actions using your script in workflow or document classes, you will be able to set specific values for these parameters for each action (for example, your script could be used as a custom action triggered by two different workflow states, and each workflow state could use different values for your script’s parameters).
Importing libraries and writing custom scripts
Configuring the parameters section of custom scripts