Function
Last updated
Last updated
Function task executes JavaScript or Groovy script.
Script Type
JavaScript or Groovy
Function
Script contents
ResultValue
The return value from the script, if exists.
UseDataStructure
Map data structure to the return value. This is used at mapping component.
DataStructureId
Data structure id for future mapping.
JDK provides JavaScript engine named Nashorn and this engine is removed since JDK 15. After JDK 15, gravalVM is used as an alternative of Nashorn engine.
And there is a slight change on JavaScript function execution after JDK 8.
8
Named function can be executed.
The last function is executed if unnamed function does not exist.
Unnamed function has the highest priority.
9+
Named function cannot be executed.
Unnamed function is executed.
function hello () {
return "Hello";
}
Hello
function () {
return "Hello";
}
Hello
function add(a,b) {
return a + b;
}
function a () {
return add(1,2);
}
3.0
function a(a, b) {
return a + b;
}
function () {
return a(1,2);
}
function b() {
return "Hello";
}
3.0
function hello () {
return "Hello";
}
Error
function () {
return "Hello";
}
Hello
function add(a,b) {
return a + b;
}
function () {
return add(1,2);
}
3
This is the definition of Groovy (from Wikipedia)
The example script of Groovy is like this.
Apache Groovy is a -syntax-compatible for the . It is both a static and language with features similar to those of , , and . It can be used as both a and a for the Java Platform, is compiled to (JVM) , and interoperates seamlessly with other Java code and .