> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Supported scripts

> Scripts are used to execute actions and configure properties inside nodes. The following script languages are supported.

## Business rules scripting

<CardGroup>
  <Card title="Python 3" icon="python" href="#python-3" />

  <Card title="MVEL" icon="code" href="#mvel" />

  <Card title="Groovy" icon="code" href="#groovy" />

  <Card title="JavaScript" icon="js" href="#javascript" />
</CardGroup>

| Scripting Language | Language Version | Default Engine (5.9.0+)                      | Opt-in Engine             |
| ------------------ | ---------------- | -------------------------------------------- | ------------------------- |
| JavaScript         | ECMAScript 2023  | Node.js V8 (subprocess pool)                 | GraalJS on GraalVM 24.1.2 |
| Python 3           | 3.11             | CPython (subprocess pool)                    | GraalPy on GraalVM 24.1.2 |
| MVEL               | 2                | `org.mvel » mvel2` 2.5.2.Final               | —                         |
| Groovy             | 3.0.21           | `org.codehaus.groovy » groovy-jsr223` 3.0.21 | —                         |

<Info>
  **Starting with 5.9.0, JavaScript and Python execute on a native subprocess pool by default.** Existing scripts that read from `input`, write to `output`, and use language built-ins keep working. `output.put(...)`, `output.get(...)`, and bracket assignment are preserved. To keep the previous GraalVM engine, set `APPLICATION_SCRIPT_ENGINE_PROVIDER=graalvm` on `process-engine` and `integration-designer`. See [Script runtime change](/5.9/migrating-from-5.1-lts/api-breaking-changes#script-runtime-change-for-javascript-and-python-business-rules) in the 5.1 → 5.9 migration guide for the full audit.
</Info>

<Info>
  In version 4.7.2, we've deprecated the **DMN (Decision Model and Notation)** business rule actions. This change affects how business rules are configured on task/user task nodes in business processes.
</Info>

<Warning>
  Python 2.7 is no longer supported. Migrate Python scripts to Python 3 to take advantage of improved performance and modern language features.
</Warning>

## Integration designer scripting

| Scripting Language | Language Version | Default Engine (5.9.0+)      | Opt-in Engine             |
| ------------------ | ---------------- | ---------------------------- | ------------------------- |
| JavaScript         | ECMAScript 2023  | Node.js V8 (subprocess pool) | GraalJS on GraalVM 24.1.2 |
| Python             | 3.11             | CPython (subprocess pool)    | GraalPy on GraalVM 24.1.2 |

***

## Input and output

Scripts in FlowX receive data through bound variables. The available variables depend on the context.

### Available variables

| Variable           | Type                   | Process business rules | Workflow scripts | Description                                                   |
| ------------------ | ---------------------- | ---------------------- | ---------------- | ------------------------------------------------------------- |
| `input`            | `Map` (read-only copy) | ✅                      | ✅                | Process instance data or workflow start node data             |
| `output`           | `Map` (mutable)        | ✅                      | ✅                | Write results here — data is persisted after script execution |
| `additionalData`   | `Map`                  | ✅                      | ✅                | Contains `securityDetails` and `applicationConfiguration`     |
| `instanceMetadata` | `Map`                  | ✅                      | ❌                | Process instance metadata (not available in workflows)        |

### Writing to output

Assign values to the `output` variable to persist data. Both assignment and `.put()` syntax work.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={"system"}
    // Dot notation
    output.clientName = input.firstName + " " + input.lastName;

    // Bracket notation
    output["totalAmount"] = input.price * input.quantity;

    // Java method (also works)
    output.put("status", "approved");

    // Nested objects
    output.address = {
      street: input.streetName,
      city: input.cityName
    };
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={"system"}
    # Bracket notation
    output["clientName"] = input["firstName"] + " " + input["lastName"]

    # Java method (also works)
    output.put("totalAmount", input["price"] * input["quantity"])

    # Nested objects
    output["address"] = {
      "street": input["streetName"],
      "city": input["cityName"]
    }
    ```
  </Tab>
</Tabs>

### Reading from input

`input` is a deep copy of the process or workflow data. Changes to `input` are not persisted. Always write to `output`.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={"system"}
    // Dot notation
    var name = input.application.client.name;

    // Bracket notation
    var code = input["application"]["countryCode"];

    // Safe access for optional fields
    var detail = input.query?.detail_level || "basic";
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={"system"}
    # Bracket notation
    name = input["application"]["client"]["name"]

    # Check before accessing optional fields
    if "countryCode" in input["application"]:
        code = input["application"]["countryCode"]
    ```
  </Tab>
</Tabs>

### Accessing configuration parameters

Retrieve project-level configuration parameters through `additionalData`:

```javascript theme={"system"}
var commission = additionalData.applicationConfiguration.get("commissionPercentage");
output.commissionValue = input.amount * commission;
```

For security details and more examples, see [Extracting additional data in business rules](./actions/business-rule-action/extracting-additional-data).

### Common pitfalls

<AccordionGroup>
  <Accordion title="Output is empty ({})">
    If your script runs without errors but output is `{}`:

    * **Check your variable names**. `output` must be spelled exactly, it's case-sensitive
    * **Check assignment syntax**. In Python, use `output["key"] = value` (bracket notation), not `output.key = value`
    * **Don't reassign output**. `output = {"key": "value"}` replaces the reference and won't persist. Use `output["key"] = "value"` instead
    * **Don't use `return`**. Scripts don't need a return statement. Write directly to `output`.
  </Accordion>

  <Accordion title="Python import errors">
    Python scripts run in a sandboxed environment. Common modules like `uuid`, `re`, and other standard library imports are not available.

    ```python theme={"system"}
    # ❌ This will fail
    import uuid
    output["id"] = str(uuid.uuid4())

    # ✅ Use alternative approaches or generate IDs in a different node
    ```
  </Accordion>

  <Accordion title="Python syntax limitations">
    Some Python patterns behave differently in the GraalPy sandbox:

    ```python theme={"system"}
    # ❌ enumerate() not available
    for i, item in enumerate(items):

    # ✅ Use manual index
    i = 0
    while i < len(items):
        item = items[i]
        i = i + 1

    # ❌ .get() with default argument may cause arity errors
    value = input.get("key", "default")

    # ✅ Check key existence first
    if "key" in input:
        value = input["key"]
    else:
        value = "default"

    # ❌ dict.items() iteration not supported
    for k, v in data.items():

    # ✅ Iterate over keys
    keys = list(data.keys())
    i = 0
    while i < len(keys):
        k = keys[i]
        v = data[k]
        i = i + 1
    ```
  </Accordion>

  <Accordion title="Java HashMap interop in JavaScript">
    When accessing data returned by Java services (such as AI node output), values may be Java HashMaps rather than native JavaScript objects. Standard JS methods like `Object.keys()` and spread syntax may not work as expected.

    ```javascript theme={"system"}
    // ❌ May not work with Java HashMaps
    var keys = Object.keys(javaMap);
    var copy = {...javaMap};

    // ✅ Use Java interop
    var value = javaMap.get("key");
    javaMap.put("key", "value");
    ```
  </Accordion>
</AccordionGroup>

### Scripts in Integration Workflows

Script nodes in [Integration Workflows](../platform-deep-dive/integrations/integration-designer) use the same `input` and `output` variables as process business rules, but the data flow is different:

* **In a process business rule**, `output` writes directly to the process instance data store.
* **In a workflow Script node**, `output` becomes the `input` for the **next node** in the workflow. The data stays within the workflow until the workflow completes at an **End** node.

Only the End node output is mapped back to the calling process (via a Receive Message Task with a "From Workflow" data stream).

<Info>
  If your workflow Script node produces an empty `output` (`{}`), subsequent nodes in the workflow receive no data. To pass all input data through to the next node while adding or modifying fields, copy the input to output first:

  ```javascript theme={"system"}
  // Copy all input data to output, then add/modify fields
  output.put("", input);
  output.ticket_id = "TICKET-" + Math.floor(Math.random() * 100000);
  output.timestamp = new Date().toISOString();
  ```

  The `output.put("", input)` call copies all keys from `input` into the root of `output`.
</Info>

For details on mapping workflow output back to your process, see [Workflow data models](../platform-deep-dive/integrations/workflow-data-models).

***

## JavaScript

<Info>
  **New in v4.7.1**: JavaScript support has been upgraded from Nashorn (ECMAScript 5.1) to GraalJS (ECMAScript 15/2024), providing significantly improved performance and modern language features.
</Info>

JavaScript in FlowX.AI is powered by GraalJS, which supports ECMAScript 15 (2024) standards. This provides modern JavaScript capabilities for your business rules and integrations.

### What is GraalJS?

GraalJS is an ECMAScript compliant JavaScript implementation built on GraalVM. It supports the latest ECMAScript features and offers high performance through the GraalVM's JIT compiler.

### Properties

* Supports ECMAScript 15 (2024) features including modern syntax and APIs
* Provides consistent scripting across business rules and integration designer
* Runs in a secure sandboxed environment

### Limitations

JavaScript scripts run in a sandboxed environment. Here is a list of JavaScript features not available in the sandbox:

* import.meta (ES2020)
* top-level await (ES2022)
* set operations (ES2024)
* Array.fromAsync (ES2024)

### Useful links

<Card title="GraalJS Documentation" href="https://www.graalvm.org/javascript/" icon="link" />

<Card title="ECMAScript 2024 Language Specification" href="https://tc39.es/ecma262/" icon="link" />

***

## Python 3

Python is a high-level, interpreted programming language known for its simplicity and readability. FlowX.AI uses Python 3.11.7 via GraalPy for executing Python scripts.

### What is GraalPy?

GraalPy is an implementation of Python that runs on the GraalVM. It offers high compatibility with standard Python (CPython) while providing the ability to run within the Java ecosystem. GraalPy supports Python 3 and provides access to a large subset of the standard Python library.

### Properties

* Supports Python 3.11.7 with access to most common Python libraries
* Runs up to 3x faster than Python 2.7 via Jython
* Runs in a sandboxed environment for better security

### Python Library Support

Python 3 support in FlowX comes with a subset of the [standard Python library](https://docs.python.org/3.11/library/index.html). Python runs in a sandboxed environment and the following modules are not available:

"stringprep", "sqlite3", "plistlib", "getpass", "curses", "curses.textpad", "curses.ascii", "curses.panel", "xml.parsers.expat", "xmlrpc.client", "xmlrpc.server", "turtle", "tkinter", "test.support", "symtable", "pyclbr", "msvcrt", "winreg", "winsound", "grp", "termios", "tty", "pty", "syslog", "audioop", "msilib", "nis", "ossaudiodev", "smtpd", "spwd", "crypt"

<Warning>
  Available modules might provide limited access to system resources due to the execution in a sandbox environment.
</Warning>

### Useful links

<Card title="Python 3.11 Documentation" href="https://docs.python.org/3.11/" icon="link" />

<Card title="GraalPy Documentation" href="https://www.graalvm.org/python/" icon="link" />

## MVEL

MVEL is an expression language for Java-based applications. It provides a plethora of features and is suited for everything from the smallest property binding and extraction, to full-blown scripts.

* FlowX.AI uses [**mvel2 - 2.5.2.Final version**](https://mvnrepository.com/artifact/org.mvel/mvel2/2.5.2.Final)

### Useful links

<Card title="MVEL Documentation" href="http://mvel.documentnode.com/" icon="link" />

<Card title="Maven repository: Mvel 2.5.2 Final" href="https://github.com/mvel/mvel/tags" icon="link" />

***

## Groovy

Groovy is a multi-faceted language for the Java platform. The language can be used to combine Java modules, extend existing Java applications and write new applications

We use and recommend **Groovy 3.0.21** version, using **groovy-jsr223** engine.

<Info>
  **Groovy** has multiple ways of integrating with Java, some of which provide richer options than available with **JSR-223** (e.g. greater configurability and more security control). **JSR-223** is recommended when you need to keep the choice of language used flexible and you don't require integration mechanisms not supported by **JSR-223**.
</Info>

<Info>
  **JSR-223** (spec) is **a standard scripting API for Java Virtual Machine (JVM) languages** . The JVM languages provide varying levels of support for the JSR-223 API and interoperability with the Java runtime.
</Info>

### Useful links

<Card title="Groovy Language Documentation" href="https://docs.groovy-lang.org/docs/groovy-3.0.21/html/documentation/" icon="link" />

<Card title="[Java] Class GroovyScriptEngineImpl" href="https://docs.groovy-lang.org/latest/html/gapi/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.html" icon="link" />

<Card title="groovy-jsr223" href="https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-jsr223" icon="link" />

***

## Academy courses

<CardGroup cols={2}>
  <Card title="Exclusive Gateways course" icon="graduation-cap" href="https://academy.flowx.ai/explore/configure-exclusive-gateways">
    Learn to configure conditions in JavaScript and DMN for gateway routing
  </Card>

  <Card title="Debug 101 course" icon="graduation-cap" href="https://academy.flowx.ai/explore/debug-your-process-0">
    Troubleshoot script execution errors, exceptions, and debugging patterns
  </Card>
</CardGroup>

<Tip>
  **Academy playground**. Explore the [**Academy\_ExclusiveGateways**](https://designer-workshop-51x.playground.flowxai.dev/workspace/00000000-0000-0000-0000-000000000001/projects/173d95f6-a1ee-447a-853c-3edee11b75b1/config/2a6fc79d-f993-4114-94d8-771104ffb650/processes) project for working examples of JavaScript and DMN conditions in gateway routing.
</Tip>
