A script is a TypeScript code that allows you to access business process data, create, query, modify and delete app items, as well as exchange data with external systems using the HTTP protocol.
Suppose a company sells products online through a website. When a client clicks Place order, a script is executed. This script launches a business process in ELMA365 and the information about new order is sent to the process. The program automatically calculates the discounts and the total, and then sends the data back to the website.
Add Script to the process
Only users included in the Administrators group can manage Script settings.
On the process page, to the right of the modeling sheet, find the Activities block. Drag the Script activity to the process diagram and place it where required.
Double-click on the Script activity to open the settings window. It contains two tabs: General and Error Handling.
In the Name field, specify the name of the operation as it will be shown in the system, for example, Calculate total amount.
In the Function field, you need to select or add a function. Functions previously added to the process are available in the drop-down list. If you need to create a new one, click Create. Specify its name using English letters, numbers, and the underscore. The function's name must begin with a letter. Click Create and then click Open.
You will be redirected to the Scripts Tab. There you can write the script that can access context variables and automate certain operations.
In certain scripts, you can use additional parameters. They allow you to optimize some process operations or make changes to the script without republishing. You can read more about this in the Additional Parameters article.
Error Handling tab
You can define the program behavior in case of process errors, for example, if ELMA365 fails to reach an external service.
To do this, open the Error Handling tab in the settings window.
- Retry. Select this option if you want the system to re-execute the script.
- Number of retries. This field indicates how many attempts the system must take to re-execute the script.
- Retry delay (sec). It determines the amount of time ELMA365 should wait before trying to re-execute the script.
- Notification. Select this option if you want to inform specific users about a script failure.
- Interrupt. In case of an error, ELMA365 will interrupt the execution of the script and resume the process. You need to select a connector to specify which process branch should be activated.
After you specify all the settings, click Save.
Found a typo? Highlight the text, press ctrl + enter and notify us