To configure your custom script:
1. Access the library administration and select Custom scripts.
2. Click the name your script to open it.
3. Under Security mode, choose the permissions with which your script will run:
- Run with current user’s privileges: the script is executed with the privileges of the user who triggers its execution. If the script tries to access a document on which the current user has no permission, the script fails with a permission denied error.
- Run with administrator’s privileges: the script has administrator access, so it can access all documents.
Important: Use this option with caution. Administrator scripts can lead to a security breach. For example, an administrator script could be used by users to gain access to documents on which they have no permissions.
4. Select your execution mode:
- Sync execution: The script is executed immediately. It can run up to 1 minute.
- Async execution: The script is triggered a few seconds after you execute the script. Use this option for scripts that perform long or a large number of actions. Scripts that run in asynchronous mode can run for up to 10 minutes. This option is available only for Workflow Transition Action scripts and Update Action scripts.
Important: Asynchronous scripts can't lock a document. For example, you can't modify the properties of documents with asynchronous scripts.
5. Under Parameters, you can configure parameters for your script and define the default value for each parameter.
When configuring actions using your script in workflows, document classes or relations, you can set specific values for these parameters for each action.
For example, your script could be configured in two different workflow states, and each workflow state could use different values for your script’s parameters.
6. In the Imports section, configure the list of classes that you want your script to import.
7. In the code editor, configure the source code of your script. Depending on the type of script, you can edit the source code of different methods. Use the Method drop-down list to select the method you want to edit:
- _execute: to execute Workflow Transition Action and Viewer Action scripts
- _isApplicable: to configure who can execute 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 as asynchronous
- _filter: to execute Relation Filter scripts
- _update: to execute Update Action scripts
- _createRelationVO: to execute Relation Render Action scripts