Zervicepoint 1.14 introduces a new powerful activity, say hi to the Code activity! The Code activity let you transform variables in the workflow using JavaScript. Now you no longer have to walk the extra mile with a call to a custom activity in order to do things like data transformation, string manipulation and validation of data.
How do you use it?
Locate the new Code activity in the workflow editor and add it to your workflow. The setup consist of two parts. Creating parameters and then the JavaScript code block.
In order for variables to be available in the code block you first have to create parameters and bind them to a variable. The function definition will automatically be updated in the code block to reflect your changes to parameters, showing which parameters will be available in the code block. Variables that you have created by yourself can be both read and assigned to in the code block. System variables can only be read and not manipulated.
In the code block you write custom JavaScript code that operates on the input parameters. By default, all input parameters are also returned but if you only want to return a subset of parmeters you can use a return statement with a custom JS object containing the parameters you want to return (shown in the title image for this post).