---
schema_version: "1"
id: 7d31aecd6a4917e473ddd1ccfb55cbedaf11425167f46c08fd565fa96d4f7b9e
title: Migrating the Enricher to a Target Variable
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.3/migration-core-enricher.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.3/migration-core-enricher
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a7465dd6d1e8bc563a15b6a93bc712b880fe7624ac3c3bfa0c6acda95355b3fa
description: MuleSoft Documentation Site
release: "4.3"
latest: false
---
---
product: Mule Runtime
version: 4.3
---

# Migrating the Enricher to a Target Variable

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

The Message Enricher and its functionality in Mule 3 is replaced by the `target` parameter in
Mule 4. The Enricher provided a way to execute a group of message processors and redirect their
output to a variable without side effects to the current message. In Mule 4, all non-void operations
(for example, `<flow-ref>`, `<http:request>`, `<db:select>`, and so on) include `target` and
`targetValue` parameters, which allow redirecting each operation’s output into a variable (such as
`myVar`). Other components in a Mule flow can then access that data through a DataWeave selector
(for example, `vars.myVar`).

## Example

Consider a message coming from an HTTP request, which we want to redirect to a third system, only
that adding a `state` query param which is to be extracted using a secondary flow called
`stateLookup`. Because you don’t want to lose the original payload or headers, you need to extract
this value without affecting the original message. The Enricher calls out to the enrichment resource
with the current message (containing the zip code), then enriches the current message with the
result.

Mule 3 example

<flow name="orderProcessingFlow">
   <http:listener .../>
   <enricher target="#\[variable:state\]">
       <flow-ref name="stateLookup"/>
   </enricher>
  <http:request config-ref="config" path="state" method="POST">
    <http:request-builder>
        <http:query-param paramName="state" value="#\[flowVars.state\]" />
    </http:request-builder>
  </http:request>
</flow>

In Mule 4, you can simply use the `target` parameter in the `<flow-ref>` operation:

Mule 4 example

<flow name="orderProcessingFlow">
  <http:listener .../>
  <flow-ref name="stateLookup" target="state" />
  <http:request config-ref="config" path="state" method="POST">
    <http:query-params>
      #\[{'state' : vars.state}\]
    </http:query-params>
  </http:request>
</flow>

## Migrate Multiple Enrichers

In Mule 4, you can set only one `target` variable per operation. If you have more than one enricher
configured in your Mule 3 application, you can achieve the same behavior in Mule 4 by using the
`Set Variable` component:

Mule 3 example

<flow name="orderProcessingFlow">
	...
	<enricher doc:name="order-enricher">
	    <flow-ref name="validator-flow" doc:name="validator-flow"/>
	    <enrich source="#\[payload.validation.result\]" target="#\[flowVars.validationResult\]"/>
	    <enrich source="#\[payload.validation.code\]" target="#\[flowVars.validationCode"/>
	</enricher>
	...
</flow>

Mule 4 example

<flow name="orderProcessingFlow">
  ...
  <flow-ref name="validator-flow" target="validation" />
  <set-variable value="#\[vars.validation.result\]" variableName="validationResult"/>
  <set-variable value="#\[vars.validation.code\]" variableName="validationCode"/>
  ...
</flow>

## See Also

- [Target Variables](https://docs.mulesoft.com/mule-runtime/4.3/target-variables)
