Newer Version Available
Implementing DataWeave in Apex (Developer Preview)
DataWeave Namespace
The DataWeave namespace provides classes and methods to support the invocation of DataWeave scripts from Apex. The Script class contains the createScript() method to load DataWeave scripts from .dwl metadata files that have been deployed to an org. The resulting script can then be run with a payload using the execute() method to obtain script output in a DataWeave.Result object. The Result class contains methods to retrieve script output using Script class methods. For more information on these classes and methods, see DataWeave Namespace.
The catchable System.DataWeaveScriptException exception is available for error handling. Runtime script exceptions that occur within DataWeave are exposed to Apex with this exception type.
DataWeave scripts support logging using the log(string, value) function. Log messages that originate from DataWeave are reflected in Apex debug logs as DATAWEAVE_USER_DEBUG events, under the Apex Code log category at the DEBUG log level.
Supporting Information
DataWeave 2.4 script syntax is supported in Apex, except for these limitations: Limitations of DataWeave in Apex (Developer Preview).
These tools support the development of DataWeave scripts.
- DataWeave Interactive Learning is an online interactive playground that you can use to test your DataWeave scripts.
- DataWeave 2.0 VSCode marketplace extension adds code highlighting and other feature support for editing DataWeave scripts.