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

# lookup

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

## lookup(flowName: String, payload: Any, timeoutMillis: Number = 2000)

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 the `lookup` function doesn’t 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.

_This function is **Deprecated**. Use
[DataWeave functions](https://docs.mulesoft.com/dataweave/latest/dataweave-functions), instead._

### 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>
```
