Inline
The inline task helps execute necessary logic at the workflow run-time using an evaluator. The two supported evaluator types are javascript and graaljs.
Definitions
{
"name": "inline_task_example",
"taskReferenceName": "inline_task_example_ref",
"type": "INLINE",
"inputParameters": {
"expression": "(function () {\n return $.value1 + $.value2;\n})();",
"evaluatorType": "graaljs",
"value1": 1,
"value2": 2
}
}
Input Parameters
Attribute | Desciption |
---|---|
evaluatorType | Choose the type of evaluator. Supported evaluators are graaljs & javascript. Graaljs evaluates the expression using graaljs, and javascript evaluates the expression using nashorn to compute the value. |
expression | Indicates the expression associated with the type of evaluator. For the javascript evaluator, the Javascript evaluation engine is used to evaluate the expression defined as a string. It must return a value. For the graaljs evaluator, graalvm is used to evaluate the expression. |
Besides the expression, any of the properties in the input values is accessible as $.value for the expression to evaluate.
Examples
- UI
- JSON Example
- Add task type
Inline
. - Write the inline script using Javascript.
{
"name": "inline_task_example",
"taskReferenceName": "inline_task_example_ref",
"type": "INLINE",
"inputParameters": {
"expression": "(function () {\n return $.value1 + $.value2;\n})();",
"evaluatorType": "graaljs",
"value1": 1,
"value2": 2
}
}
tip
The JSON definition shows a string format of the script; however, on the UI, it will retain the formatting we used and is more readable.