Scripting
Node
11 min
the node action is one of the actions at your disposal that allows you to execute javascript code module imports can be performed using commonjs require('module') syntax only the list of currently allowed modules can be found below uuid https //www npmjs com/package/uuid https //www npmjs com/package/uuid axios https //www npmjs com/package/axios https //www npmjs com/package/axios cheerio https //www npmjs com/package/cheerio https //www npmjs com/package/cheerio underscore https //www npmjs com/package/underscore https //www npmjs com/package/underscore ramda https //www npmjs com/package/ramda https //www npmjs com/package/ramda validator https //www npmjs com/package/validator https //www npmjs com/package/validator lodash https //www npmjs com/package/lodash https //www npmjs com/package/lodash xml https //www npmjs com/package/xml https //www npmjs com/package/xml use the return keyword to set the output value you can return either single values or list values , not both at same time timeout โ integer representing execution time limit(when timeout limit is reached, the action will throw an error) single result โ output that will be set for single value outputs list result โ output that will be set for list value outputs error โ string representing errors resulted from the execution of the script (the output is set only when an error occurs, otherwise itโs null ) something to consider before trying to use the node action to automate your use cases is that it does not support working with files how to configure the node action? create a process and name it drag the node action to the canvas and link it to the other actions 3\ create the variables needed for the configuration of the action, and then add them to the configuration panel 4\ add your javascript code to the editor 5\ configure the output variables which will store the results 6\ save, validate and run 7\ click checked instance to view the results you will see that the outcome of the interpreted code is saved in the result variable the script ran without errors so the value of the errormessage variable is null usage examples 1\ timeout obs if you set the timeout to 5 seconds, the action will throw an error at runtime 2\ scripts with single outputs integer integer float float string string boolean boolean json / datamodel json / datamodel datetime datetime obs these should only set the single output should work for all types 3\ scripts with list outputs obs these should only set the list output should work for all types, just like single values 4 basic module usage if the module does not support commonjs require , we canโt use it 5 syntax errors obs syntax errors will only set the error field 6 throw behavior obs exception messages thrown using throw โmessageโ syntax will show up on the error field only error will be set after execution 7 async / await