Nav

Using lookup To Call External Flows

From a DataWeave transform, you can trigger the calling of a different flow in your Mule application, and whatever the flow returns is what the expression returns.

You can do this through the following expression:

lookup(“flowName”,$)

Which takes two parameters:

  • The name of the flow that must be called

  • The payload to send to this flow

Transform

         
      
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
  a: lookup("mySecondFlow",{b:"Hello"})
}
Mule Flow

         
      
1
2
3
<flow name="mySecondFlow">
    <set-payload doc:name="Set Payload" value="#[payload.b + ' world!' ]"/>
</flow>
Output

         
      
1
2
3
{
  "a": "Hello world!"
}

Please note that only the payload returned by the invoked flow will be assigned.

Note that lookup function does not support calling subflows.

In this topic: