---
schema_version: "1"
id: 4634d33fd94067fa08d33bcd137b4221cf7b4910a5211b3c3e149d485e778250
title: Migrating the Scripting Component
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.4/migration-module-scripting.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.4/migration-module-scripting
source_site: docs.mulesoft.com
content_type: documentation
content_hash: f647007f296a08d359decd8c1a37b4e9b6f696da23ea803f7ec2d63151ddc2b6
description: MuleSoft Documentation Site
release: "4.4"
latest: false
---
---
product: Mule Runtime
version: 4.4
---

# Migrating the Scripting Component

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

The `<scripting>` component in Mule 3 is replaced with a new `<scripting>` module. This new module
is pretty similar in functionality, with just some syntax changes:

Mule 3 Example: Scripting

```xml
 <flow name="greedy">
    <choice>
        <when expression="#[flowVars['currency'] == 'USD']">
            <scripting:component>
                <scripting:script file="greedy.groovy">
                    <property key="currency" value="USD"/>
                </scripting:script>
            </scripting:component>
            </when>
        <when expression="#[flowVars['currency'] == 'GBP']">
            <scripting:component>
                <scripting:script file="greedy.py">
                    <property key="currency" value="GBP"/>
                </scripting:script>
            </scripting:component>
            </when>
    </choice>
</flow>
```

-

Mule 4 Example: Scripting

```xml
 <flow name="greedy">
    <scripting:execute engine="groovy">
        <scripting:code>${file::greedy.groovy}</scripting:code>
        <scripting:parameters>
            #[{currency: vars.currency}]
        </scripting:parameters>
    </scripting:execute>
</flow>
```

As you can see, the main difference here is that now you can use DataWeave to generate the input
parameters.

## Accessing Variables from the Script

The previous example uses a variable to show how to pass parameters into the script, it’s best to
keep the script decoupled from the rest of the flow, so that changes to the Mule applications don’t
require changes to the script.

However, you can still access the variables from the script using the `vars` keyword. For example:

Mule 4 Example: Accessing variables directly

```xml
<flow name="greedy">
    <scripting:execute engine="groovy">
        <scripting:code>return "currency is " + vars.currency</scripting:code>
    </scripting:execute>
</flow>
```

To use the Scripting Module, simply add it to your application using the Studio palette or add the
following dependency in your `pom.xml` file:

```xml
<dependency>
  <groupId>org.mule.modules</groupId>
  <artifactId>mule-scripting-module</artifactId>
  <version>1.1.0</version> <!-- or newer -->
  <classifier>mule-plugin</classifier>
</dependency>
```

## See Also

- [Scripting Module Documentation](https://docs.mulesoft.com/scripting-module/latest/)
