---
schema_version: "1"
id: 952b8523c25d07ad479b826b9cae77df48582b5a48ef28c612e31133efe55143
title: lookup
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-mule-functions-lookup.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-mule-functions-lookup
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 98f0c8855c38ada038f6a80a707f7e83784d5e1a5494d7c3178b042ef6006423
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# lookup

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

## lookup(String, Any, Number)

This function enables you to execute a flow within a Mule app and retrieve the resulting payload.

It works in Mule apps that are running on Mule Runtime version 4.1.4 and later.

Similar to the Flow Reference component (recommended), the `lookup` function enables you to execute
another flow within your app and to retrieve the resulting payload. It takes the flow’s name and an
input payload as parameters. For example, `lookup("anotherFlow", payload)` executes a flow named
`anotherFlow`.

The function executes the specified flow using the current attributes, variables, and any error, but
it only passes in the payload without any attributes or variables. Similarly, the called flow will
only return its payload.

Note that `lookup` function does not support calling subflows.

> [!WARNING] Always keep in mind that a functional language like DataWeave expects the invocation of
> the `lookup` function to _not_ have side effects. So, the internal workings of the DataWeave
> engine might cause a `lookup` function to be invoked in parallel with other `lookup` functions, or
> not to be invoked at all.
>
> MuleSoft recommends that you invoke flows with the Flow Ref (`flow-ref`) component, using the
> `target` attribute to put the result of the flow in a `var` and then referencing that `var` from
> within the DataWeave script.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>flowName</code></p></td><td><p>A string that identifies the target flow.</p></td></tr><tr><td><p><code>payload</code></p></td><td><p>The payload to send to the target flow, which can be any (<code>Any</code>) type.</p></td></tr><tr><td><p><code>timeoutMillis</code></p></td><td><p>Optional. Timeout (in milliseconds) for the execution of the target flow. Defaults to <code>2000</code> milliseconds (2 seconds) if the thread that is executing is CPU_LIGHT or CPU_INTENSIVE, or 1 minute when executing from other threads. If the lookup takes more time than the specified <code>timeoutMillis</code> value, an error is raised.</p></td></tr></tbody></table>

### Example

This example shows XML for two flows. The `lookup` function in `flow1` executes `flow2` and passes
the object `{test:'hello '}` as its payload to `flow2`. The Set Payload component (`<set-payload/>`)
in `flow2` then concatenates the value of `{test:'hello '}` with the string `world` to output and
log `hello world`.

#### Source

```XML
<flow name="flow1">
  <http:listener doc:name="Listener" config-ref="HTTP_Listener_config"
    path="/source"/>
  <ee:transform doc:name="Transform Message" >
    <ee:message >
      <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
Mule::lookup('flow2', {test:'hello '})]]></ee:set-payload>
    </ee:message>
  </ee:transform>
</flow>
<flow name="flow2" >
  <set-payload value='#[payload.test ++ "world"]' doc:name="Set Payload" />
  <logger level="INFO" doc:name="Logger" message='#[payload]'/>
</flow>
```
