Inline
The inline task is used to execute scripting logic during workflow runtime by evaluating a JavaScript expression using an evaluator like GraalJS.
Task parameters
Configure these parameters for the Inline task.
Parameter | Description | Required/ Optional |
---|---|---|
inputParameters. expression | The JavaScript expression to be evaluated by the GraalJS evaluator. | Required. |
inputParameters. evaluatorType | The type of evaluator used. Supported types:
| Required. |
inputParameters | The parameters for evaluating the script. Any property can be accessed as $.value for the expression to evaluate. | Required. |
Schema parameters
You can enforce input/output validation for the task using the following parameters. Refer to Schema Validation for a full guide.
Parameter | Description | Required/ Optional |
---|---|---|
taskDefinition.enforceSchema | Whether to enforce schema validation for task inputs/outputs. Set to true to enable validation. | Optional. |
taskDefinition.inputSchema | The name and type of the input schema to be associated with the task. | Required if enforceSchema is set to true. |
taskDefinition.outputSchema | The name and type of the output schema to be associated with the task. | Required if enforceSchema is set to true. |
Other generic parameters
Here are other parameters for configuring the task behavior.
Parameter | Description | Required/ Optional |
---|---|---|
optional | Whether the task is optional. The default is false. If set to true, the workflow continues to the next task even if this task is in progress or fails. | Optional. |
Task configuration
This is the task configuration for an Inline task.
{
"name": "inline",
"taskReferenceName": "inline_ref",
"type": "INLINE",
"inputParameters": {
"expression": "(function () {\n return $.value1 + $.value2;\n})();",
"evaluatorType": "graaljs",
"value1": 1,
"value2": 2
}
}
Task output
The Inline task will return the following parameters.
Parameter | Description |
---|---|
result | Returns the results of the evaluated script. |
Adding an Inline task in UI
To add an Inline task:
- In your workflow, select the (+) icon and add an Inline task.
- In Script params, add the parameters that will be evaluated in the expression.
- Enter the expression to be evaluated in the Code section. The JSON definition offers a concise string representation of the script, whereas the UI representation typically incorporates formatted indentation and line breaks to enhance user readability.
Examples
Here are some examples for using the Inline task.
Using the Inline task in a workflow
An Inline task can be used for simple scripting logic that does not require a dedicated custom worker. In this example workflow, the Inline task is used to reverse a string based on the user input.
// the expression evaluated in the Inline task
(function () {
return $.input_string.split("").reverse().join("");
})();
Here is the full workflow definition containing the Inline task.
{
"name": "String_Reverser",
"description": "A workflow to reverse a string",
"version": 1,
"tasks": [
{
"name": "string_reverser",
"taskReferenceName": "string_reverser_ref",
"inputParameters": {
"expression": "(function(){ return $.input_string.split('').reverse().join('');})();",
"evaluatorType": "graaljs",
"input_string": "${workflow.input.in_str}"
},
"type": "INLINE"
}
],
"inputParameters": ["in_str"],
"outputParameters": {},
"failureWorkflow": ""
}