Newer Version Available

This content describes an older version of this product. View Latest

DataWeave in Apex (Beta)

DataWeave in Apex uses the Mulesoft DataWeave library to read and parse data from one format, transform it, and export it in a different format. You can create DataWeave scripts as metadata and invoke them directly from Apex. Like Apex, DataWeave scripts are run within Salesforce application servers, enforcing the same heap and CPU limits on the executing code.

This feature is a Beta Service. Customer may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms. You can provide feedback and suggestions for the DataWeave in Apex feature in the Trailblazer Community. The beta release of DataWeave in Apex supports packaging of DataWeave scripts within a namespace. However, you can only access scripts within a package, not across different namespaces.

Note

Enterprise applications often require transformation of data between formats such as CSV, JSON, XML, and Apex objects. DataWeave in Apex complements native Apex support for JSON and XML processing, and makes data transformation easier to code, more scalable, and efficient. Apex developers can focus more on solving business problems and less on addressing the specifics of file formats.

DataWeave is the MuleSoft expression language for accessing, parsing, and transforming data that travels through a Mule application. For detailed information, see DataWeave Overview

You don’t have to be a MuleSoft customer or have any specific Salesforce license to use DataWeave in Apex.

Note

The following are some use-cases for DataWeave in Apex.

  • Serializing Apex objects with custom date formats
  • Serializing and deserializing JSON with Apex reserved keywords
  • Performing custom transformations like removing or adding namespaces or removing __c suffixes
  • Parsing and transforming RFC 4180 compliant CSV (Comma-Separated Values) data