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.
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
An arbitrary set of Input and Output Parameters can be created. These objects can be accessed by ID from within the script editor.
icon. The parameter gets added to parameter
definition table.
Figure: Parameter Mapping
Figure: Primitive Data
Figure: Structured Data
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.
Specify the script in this tab. Following script language is supported:
Figure: Configuration - JavaScript
Figure: Configuration - Python
The editor provides auto-completion for keywords and parameter definitions.
Figure: Auto-completion for code keyword
Figure: Auto-completion for parameter definition
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
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.

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.

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

The test of this script shows the expected result.
