The Execute Script rule executes a script using the document at hand.
By default scripts run synchronously. This means that BizzStream will wait for the script to complete before the next rule in the action will be executed.
The maximum execution time of a script (per document) is 3 minutes. After three minutes the rule will end with an error 'Connection has timed out' that can be found in the logs.
The rule can be added to:
- User actions
- Bulk actions
- Scheduled actions
- Rest actions
|Label||No||A brief description of the rule. This description is visible in the list of rules and meant to distinguish similar rules from each other.|
|Description||No||A longer description of the rule. You can use this field to describe the purpose of the rule is.|
|Script||Yes||The script to execute.|
|Execute Asynchronously||No||Check this to execute the script asynchronously (see below).|
|Preload Data||No||Click on this button to configure the data that needs to be preloaded when the script executes (see below).|
|Execute Only If||No||The condition that needs to be met in order for this rule to execute. If this field is empty, the rule will always be executed.|
When a script runs asynchronous, BizzStream will not wait on the result of the script. It will invoke the execution of the script and will continue executing the next rule (if present) in the user action. This option obviously improves the performance experience of the end user. Not alle scripts are suitable for asynchronously execution due to the following limitations:
- It is not possible to use notifications and goToURL statements in asynchronous scripts.
- To guarantee correct execution of sequential rules, these rule may not depend on the mutations of an asynchronous script because they might not have been processed.
Note: When a user/visitor triggers a user action on a document, the document gets locked and a spinner appears until the user action has been completed. If the user action contains an asynchronously executed script that updates the document that the user is editing, a notification may appear that ask you whether you want to reload the document because "it has been changed by another user."
Note: When the Execute Script rule is executed, a log is created. This log contains the Elapsed Time field, which indicates the total time needed for processing the script.
Due to performance, a script can be provided with preloaded data. Preloaded data can been seen as a collection of document collection that can be used in scripts. By passing preloaded data to a script will eliminate the need for (relatively) slow persistent calls (for instance persistent.getDocument) because the data is already available.
You can determine the data that needs to be preloaded by clicking on the Preload Data button. A dialog will open up containing a treeview:
The first level of the treeview contains the reference fields in the document definition. When this is expanded, you will see the fields in the document definition of the referenced document. By checking these, you can indicate which fields are preloaded. If a referenced document contains reference fields, it again possible to expand these and select the fields that you want to preload.
By preloading data, you can fetch this form the
actionInfo.preloadData object. See the Action Info article for more information.