Skip to main content

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.

ParameterDescriptionRequired/ Optional
inputParameters. expressionThe JavaScript expression to be evaluated by the GraalJS evaluator.Required.
inputParameters. evaluatorTypeThe type of evaluator used. Supported types:
  • graaljs - Evaluates the JavaScript expression and computes the value.
Required.
inputParametersThe parameters for evaluating the script. Any property can be accessed as $.value for the expression to evaluate.Required.

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.

ParameterDescription
resultReturns the results of the evaluated script.

Adding an Inline task in UI

To add an Inline task:

  1. In your workflow, select the (+) icon and add an Inline task.
  2. In Script params, add the parameters that will be evaluated in the expression.
  3. 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.

Adding wait task

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 containing the Inline task.

// workflow definition

{
"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": ""
}