Skip to content

BasicDataWeaveInApexRecipes

pozil edited this page Feb 13, 2024 · 4 revisions

BasicDataWeaveInApexRecipes

Demonstrates various ways of invoking a DataWeave scripts in Apex. Note that this class demonstrates both static and dynamic way of invoking DataWeave scripts.

Group DataWeaveInApex Recipes

Methods

public static String staticInvocation()

Invokes a DataWeave script in Apex using static invocation. Uses the /dw/helloWorld.dwl DataWeave script to log a message. This shows how to invoke the script using the Apex class that is automatically generated by the platform from the DataWeave script. The DataWeave script is deployed as metadata.

Returns

Type Description
String output of the DataWeave script as a string (hard coded to "Hello World")

public static String dynamicInvocation(String scriptName)

Invokes a DataWeave script in Apex using dynamic invocation thanks to DataWeave.Script.createScript().

Parameters

Param Description
scriptName name of the DataWeave metadata to invoke

Returns

Type Description
String output of the DataWeave script as a string

Clone this wiki locally