List of predefined variables in Dataweave of Mule 4

Here is the list of predefined variables in Dataweave. You cannot use these variables in your Mule event for any other purposes. This list of predefined variables in mule 4 gives us useful information on Mule event, message, server, and others.
app
The Mule artifact in context.
Example: #[app.name] might return your application name.
flow (Deprecated)
The name of the current flow. Because flow names are static, this field is deprecated and only available through the Logger component.
Example: #[flow.name] returns sample_flowName in the Studio console when executed within a Flow with the name sample_flowName.
payload
It gives you the body of the current Mule message object (message) being processed.
Example: #[payload] returns the body of the message.
vars
All variables currently set on the current Mule event flow being processed.
Example: #[vars.varName] returns the value of varName.
attributes
Attributes (metadata) of a Mule Message object (message).
Example: #[attributes] returns message attributes. For an HTTP request, #[attributes.queryParams] returns HTTP queryParams metadata, and #[attributes.version] returns HTTP/1.1
Must read: How to use p() function in Dataweave to read property file
authentication
Provides access to the authentication information of the Mule application.
Example: #[authentication.properties]
correlationId
The correlationId of the message being processed.
Example: #[correlationId] might return e-fdfjd-324f204-545345-cer34f-323fd3.
dataType
Data type of the message payload.
Example: #[dataType] might return SimpleDataType.
error
Error associated with a Mule message object.
Example: #[error.errorMessage]
Must read: How to format date time in Dataweave now() function Mulesoft
mule
The Mule instance on which the application is currently running.
Example: #[mule.version] might return 4.3.0.
message
Package (payload and attributes) being processed.
Example: #[message] returns attributes along with the payload
server
The operating system on which the Mule instance is running. Reveals information about both the physical server and the JVM on which Mule runs.
Example: #[server.timeZone] might returns server's timezone
0 Comments