Contact Us 1-800-596-4880

Add Another Output to the Transform Message Component (Anypoint Studio)

Standard Support for Mule 4.1 ended on November 2, 2020, and this version of Mule reached its End of Life on November 2, 2022, when Extended Support ended.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

A single Transform Message component can give shape to several different parts of the output Mule event (the payload, variables, and attributes). Each different output part must be defined in a separate target XML element inside the <ee:transform> XML element as anther block of DataWeave code. In Anypoint Studio 7, you do this by writing the DataWeave code in a separate tab of the Transform pane. For example, if one tab defines the payload, and another attributes, these are both parts of the same output Mule event.

To add a new output target:

  1. Click Add new target.

    using dataweave in studio 34a3e

  2. Specify where in the output Mule message to place the result of this new DataWeave transform. In case you’re creating a new variable or property, you must also set a name for it.

    new variable

Note that the execution order of multiple outputs can vary. Ensure that each transformation is independent of the order of execution and the other outputs.

How Targets of a Transform Message Component are Represented in the Configuration XML File

The payload is represented in an <ee:message> element, as a child element of the <ee:message> element.

<ee:transform doc:name="Set Transactions XML" doc:id="5c58d889-896d-495a-b2f6-fe1613ae8044" >
  <ee:message >
    <ee:set-payload ><![CDATA[%dw 2.0
                              output application/xml
                              ...]]>

Attributes are represented together inside the <ee:message> element, as a child of the <ee:message> element.

<ee:transform doc:name="Set Transactions XML">
  <ee:message >
    <ee:set-payload ><![CDATA[%dw 2.0
                              output application/xml
                              ...]]>
    </ee:set-payload/>

    <ee:set-attributes>
    <![CDATA[%dw 2.0
             output application/java
             ---
            { }]]>
    </ee:set-attributes>
  </ee:message>
  ...
</ee:transform>

Each variable is represented inside a separate <ee:variable> element, as a child the <ee:variables> parent element. The <ee:variables> element is a direct child of the <ee:transform> element, so it is not part of the <ee:message> element. This XML structure reflects that variables and the message are carried along together with the parent event object.

Here is an example of a variable target defined inside a Transform Message component:

<ee:transform doc:name="Set accounts var" doc:id="15e226ab-8204-4d84-ab4b-f4fcdd088656">
  <ee:message>
  ...
  </ee:message>
  <ee:variables>
    <ee:set-variable variableName="accounts">
      <![CDATA[%dw 2.0
               output application/json
               ---
               ...]]>
    </ee:variable>
  </ee:variables>
</ee:transform>