You can declare script variables directly in the script body to make values available to a script during execution and to define values that can be returned to a process.
Declared variables can be assigned values from script variables by using the variables. prefix. During script execution, input variables provide values to the script, which can then be assigned to declared variables and used in calculations or other operations.
For example, the script variables cost and orders can receive their values from process variables. These values can then be assigned to declared variables:
let costOfItem = variables.cost; let numberOfOrders = variables.orders;
After the script performs its calculations, you can assign the result to an output script variable:
variables.totalCost = costOfItem * numberOfOrders;
The totalCost script variable can then be mapped to a process variable and made available to the rest of the process. For more information, see Mapping Process Variables.