---
schema_version: "1"
id: 76c4c1958b6d83d9a10144b35e34b38b97291dcd00fae2522f75c93a09f69e82
title: Scripting Module - Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/scripting-module/latest/scripting-module-examples.md
canonical_url: https://docs.mulesoft.com/scripting-module/latest/scripting-module-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 942cc4f60be4d9aec4973efeaa21e5f38b15659e5e5a65f34174b20aaa66ed93
description: MuleSoft Documentation Site
release: "2.1"
latest: true
---
---
product: Scripting Module
version: 2.1
is-latest-version: true
---

# Scripting Module - Examples

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

The following Scripting module examples show you how to use binding variables and how to access the
registry.

## Use Binding Variables Example

The following Scripting Module XML example shows how to:

- Use a flow variable in the scripting code, such as `vars.increment`

- Use scripting parameters by referencing them, such as `initialValue`

- Log some information by using the `log` variable, such as `log.info("…​.")`

- Use the `result` variable to set the result of the execution

- Define the payload in `vars.increment + Number(payload) + initialValue`

```xml
<set-variable variableName="increment" value="#[22]" />
<scripting:execute engine="ECMAScript">
    <scripting:code>
        log.info("Incrementing payload by " + (vars.increment + initialValue))
        result = vars.increment + Number(payload) + initialValue
    </scripting:code>
    <scripting:parameters><![CDATA[#[{ initialValue: 10 }]]]></scripting:parameters>
</scripting:execute>
```

## Access the Registry Example

The following Scripting Module XML example shows how to:

- Access the registry

- Stop or start a flow

```xml
<scripting:execute  engine="Groovy">
    <scripting:code ><![CDATA[flow = registry.lookupByName("test-flow").get();
        if (flow.isStarted())
	        flow.stop()
        else
	        flow.start()]]>
    </scripting:code>
</scripting:execute>
```

## See Also

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