---
schema_version: "1"
id: f816b990896712d541520479792d1abf1c368a3ba453a0176d00a776b9c1a1f4
title: Scripting Module Reference
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/scripting-module/latest/scripting-reference.md
canonical_url: https://docs.mulesoft.com/scripting-module/latest/scripting-reference
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 83f4e629b24abbac18a1db3a35baa5da8277ea8fea8af645e72a7e5271cfbfe8
description: MuleSoft Documentation Site
release: "2.1"
latest: true
---
---
product: Scripting Module
version: 2.1
is-latest-version: true
---

# Scripting Module Reference

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Scripting Module v2.1

The Scripting module executes custom logic written in a scripting language.

## Configurations

---

### Config

Default configuration

#### Parameters

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Name</p></td><td><p>String</p></td><td><p>The name for this configuration. Connectors reference the configuration with this name.</p></td><td></td><td><p>x</p></td></tr></tbody></table>

## Operations

### Execute

`<scripting:execute>`

Run a script with provided code, according to the engine and passing parameters. The script provides
many binding variables to work with:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p>payload</p></td><td><p>Object</p></td><td><p>The payload of the message processed.</p></td></tr><tr><td><p>dataType</p></td><td></td><td><p>Data type of the message payload.</p></td></tr><tr><td><p>correlationId</p></td><td><p>String</p></td><td><p>The correlationId of the message processed.</p></td></tr><tr><td><p>attributes</p></td><td><p>Map&lt;String, Object&gt;</p></td><td><p>Attributes of the Mule message processed.</p></td></tr><tr><td><p>vars</p></td><td><p>Map&lt;String, Object&gt;</p></td><td><p>The variables set on the current Mule event processed.</p></td></tr><tr><td><p>message</p></td><td></td><td><p>The message processed.</p></td></tr><tr><td><p>error</p></td><td></td><td><p>Error associated with the Mule message processed.</p></td></tr><tr><td><p>authentication</p></td><td></td><td><p>Information about the authentication.</p></td></tr><tr><td><p>flow</p></td><td><p>String</p></td><td><p>The name of the current flow.</p></td></tr><tr><td><p>log</p></td><td><p>Logger</p></td><td><p>Logger object that logs to the app’s log file, <code>MULE_HOME/logs/&lt;app-name&gt;.log</code></p></td></tr><tr><td><p>result</p></td><td><p>Object</p></td><td><p>Variable representing the result of the script execution.</p></td></tr><tr><td><p>registry</p></td><td><p>org.mule.runtime.api.artifact.Registry</p></td><td><p>Use the registry object to access any other service within the Mule API.</p></td></tr></tbody></table>

> [!NOTE] If the code doesn’t produce an implicit result, you have to set the `result` variable
> value explicitly with the execution result. The payload is set with this value unless you
> configure a [target variable](https://docs.mulesoft.com/mule-runtime/latest/target-variables) as described in
> [Scripting Module Overview](https://docs.mulesoft.com/scripting-module/latest/).

#### Parameters

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Code</p></td><td><div><div><p>String</p></div></div></td><td><p>The script source code to execute</p></td><td></td><td><p>x</p></td></tr><tr><td><p>Engine</p></td><td><div><div><p>String</p></div></div></td><td><p>Name of the scripting engine for running this script</p></td><td></td><td><p>x</p></td></tr><tr><td><p>Parameters</p></td><td><div><div><p>Map&lt;String, Object&gt;</p></div></div></td><td><p>Variables provided to the script as bindings</p></td><td></td><td></td></tr><tr><td><p>Execution Mode</p></td><td><div><div><p>Enumeration, one of:</p></div><div><ul><li><p>AUTO</p></li><li><p>INTERPRETED</p></li></ul></div></div></td><td><p>Determines whether the script is automatically compiled or forced to be interpreted. When set to <code>AUTO</code> or not specified, the module analyzes the context to determine the appropriate mode. When set to <code>INTERPRETED</code>, the module enforces interpretation mode.</p></td><td><p>AUTO</p></td><td></td></tr><tr><td><p>Target Variable</p></td><td><div><div><p>String</p></div></div></td><td><p>The name of a variable on which to place the operation’s output</p></td><td></td><td></td></tr><tr><td><p>Target Value</p></td><td><div><div><p>String</p></div></div></td><td><p>An expression to evaluate against the operation’s output. The outcome of that expression will be stored in the target variable.</p></td><td><p>#[payload]</p></td><td></td></tr></tbody></table>

> [!IMPORTANT] You must export the classes used with the Scripting Module, otherwise, the execution
> fails with a `SCRIPTING:COMPILATION` error. See
> [how to export resources](https://docs.mulesoft.com/mule-runtime/latest/how-to-export-resources).

#### Throws

- SCRIPTING:COMPILATION

- SCRIPTING:UNKNOWN\_ENGINE

- SCRIPTING:EXECUTION

## Types

### Aggregation Attributes

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Field</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Aggregation Id</p></td><td><div><div><p>String</p></div></div></td><td><p>Aggregation ID that comes from the event’s message correlationId. If the aggregator does not aggregate by correlationId, then this field is an autogenerated value for the current aggregated group.</p></td><td></td><td><p>x</p></td></tr><tr><td><p>First Item Arrival Time</p></td><td><div><div><p>Number</p></div></div></td><td><p>Time in which the first aggregated value arrived.</p></td><td></td><td><p>x</p></td></tr><tr><td><p>Last Item Arrival Time</p></td><td><div><div><p>Number</p></div></div></td><td><p>Time in which the last aggregated element arrived.</p></td><td></td><td><p>x</p></td></tr><tr><td><p>Is Aggregation Complete</p></td><td><div><div><p>Boolean</p></div></div></td><td><p>A boolean value that indicates the completion of the aggregation.</p></td><td><p>false</p></td><td></td></tr></tbody></table>

### Redelivery Policy

Configures the redelivery policy for executing requests that generate errors. You can add a
redelivery policy to any source in a flow.

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Field</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Max Redelivery Count</p></td><td><div><div><p>Number</p></div></div></td><td><p>Maximum number of times that a redelivered request can be processed unsuccessfully before returning a REDELIVERY_EXHAUSTED error.</p></td><td></td><td></td></tr><tr><td><p>Use Secure Hash</p></td><td><div><div><p>Boolean</p></div></div></td><td><p>If <code>true</code>, Mule uses a secure hash algorithm to identify a redelivered message.</p></td><td></td><td></td></tr><tr><td><p>Message Digest Algorithm</p></td><td><div><div><p>String</p></div></div></td><td><p>Secure hashing algorithm to use if the &lt;b&gt;Use Secure Hash&lt;b/&gt; field is <code>true</code>. If the payload of the message is a Java object, Mule ignores this value and returns the value that the payload’s <code>hashCode()</code> returned.</p></td><td></td><td></td></tr><tr><td><p>Id Expression</p></td><td><div><div><p>String</p></div></div></td><td><p>One or more expressions that determine when a message was redelivered. This property can be set only if the &lt;b&gt;Use Secure Hash&lt;/b&gt; field is <code>false</code>.</p></td><td></td><td></td></tr><tr><td><p>Object Store</p></td><td><div><div><p>ObjectStore</p></div></div></td><td><p>Configures the object store that stores the redelivery counter for each message.</p></td><td></td><td></td></tr></tbody></table>

## See Also

- [Scripting Module Release Notes](https://docs.mulesoft.com/release-notes/mule-runtime/module-scripting)

- [Salesforce Help](https://help.salesforce.com)
