Hear from Salesforce leaders on how to create and deploy Agentforce agents.
Contact Us 1-800-596-4880

Use Constant Directives

This DataWeave example builds URLs from constants that are defined as variables (var) in the DataWeave header. It also conditionally outputs fields if they are present in the input. Before you begin, note that 2.x versions of DataWeave are used by Mule 4 apps. For DataWeave in Mule 3 apps, refer to DataWeave version 1.2 examples. For other DataWeave versions, you can use the version selector in the DataWeave table of contents.

The example uses these functions:

  • ++ (concatenate) to build constant directives into URLs.

  • map to go through the fields in the input.

  • if to output summary and brand fields.

DataWeave Script:
Input XML Payload:
Output JSON: