The Script activity is a piece of TypeScript code that allows you to access data in business process, create, request, modify, and delete app items, and exchange data with external systems using the HTTP protocol.
Let’s say a company sells products online on a website. When a client clicks Place order, a script is executed. This script launches a business process in ELMA365, and the information about the new order is passed to the process. The system automatically calculates the discounts and the total and then sends this data back to the website.
Add the Script activity to the process
начало внимание
Only users included in the Administrators group can configure the Script activity.
конец внимание
On the process page, to the right of the modeling canvas, find the activities panel and open the Standard elements tab. 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.
General tab
In the Name* field, specify the name of the operation as it will be shown in the diagram, for example, Calculate total amount.
In the Function field, you need to link a specific function to the activity. Functions previously added to the process are available in the drop-down list. If you need to create a new one, click Create. Specify the function’s name using Latin letters, numbers, and the underscore. The function’s name must begin with a letter. Click Create and then Open.
You will be redirected to the script editor in the business process designer. Here you can write scripts to work with the business process context. These scripts are executed on the server side, so access restrictions configured for app items are not applied. For example, if access to items in an app is restricted, an item that the current user doesn’t have access to can still be loaded; the server script will run successfully. If a script gets a list of an app’s items, all items in the app will be returned.
начало внимание
Scripts are written in the TypeScript programming language. To learn about the principles of script-writing in ELMA365, please visit ELMA365 TS SDK.
конец внимание
In certain scripts, you can use additional parameters. They allow you to optimize some process operations or make changes to the script without republishing. 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 access an external service.
To do this, open the Error Handling tab in the activity 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 to re-execute the script the system will make.
- 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 the error.
- 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 has to be activated.
When you configure the settings, click Save.
Found a typo? Highlight the text, press ctrl + enter and notify us