Script Invocation Application

Scripting languages such as JavaScript or Python give the process designer the ability to manipulate, transform and convert data very easily without the need to compile code. With scripting languages, the modeler can write scripts for string manipulation, formula calculation, etc. Also, scripting languages could be tested on the fly at design time.

The Stardust Script Invocation application allows to create scripts that can access the process instance data. It also allows users to create Java Scripts that execute on activity activation.

You can perform the following operations on a Script Invocation Application.

Viewing and Editing Properties

Following properties should be specified:


Figure: Properties - Script Invocation Application

In case you switch to the Integrator profile, UUID and ID options are displayed additionally.


Figure: UUID and UI Properties

Parameters

An arbitrary set of Input and Output Parameters can be created. These objects can be accessed by ID from within the script editor.

Test

The script code can be tested at design time from the Test tab by following the steps below:


Figure: Testing Java Script Execution

You can check the execution results in the Output box.

Configuration

Specify the script in this tab. The Transacted check box specifies whether to use transacted mode. Following script languages are supported:

Code completion

The editor provides auto-completion for keywords and parameter definitions.

Auto-completion
Figure: Auto-completion for code keyword

Auto-completion
Figure: Auto-completion for parameter definition

Comments

Click the Comments tab to add comments for the application. To add the comment, specify the comment in the text box and click Submit. The newest comment gets displayed at the top of the table. To delete the comment, select the comment and click the Delete icon. The user, who has submitted the comment, can delete that comment. If the other user selects the comment or no comment is selected, the Delete icon remains in disabled state.


Figure: Comments

Examples

JavaScript Example

This process shows how to concatenate two strings using JavaScript code.

The input entered manually by the user is a structured data TwoStrings that contains two string variables (String1 and String2). The output is a primitive data.

In this case, the JavaScript code concatenates the text of the two strings and sets the result to the output variable.

This is an example of test at design time to verify the behavior of the JavaScript code.

After deploying the model and starting the process, enter two string values.

The output activity displays these text values concatenated.

Python Example

This example shows how to use Python script code to perform numeric calculation. It has the same logic as the previous one with JavaScript. The difference is in the Configuration tab, where we select Python instead of JavaScript and implement the logic in Python.

We use a structured data with two attributes of type Number (Value1 and Value2), which will be used as input parameters and a primitive data of type Number to be used as output parameter.

Parameters

In the Configuration section, we select Python and enter code to multiply the two input parameters and save the value in the output parameter.

Configuration

The test of this script shows the expected result.