DataWeaveResource

Represents the DataWeaveScriptResource class that is generated for all DataWeave scripts. DataWeave scripts can be directly invoked from Apex.

Parent Type 

This type extends MetadataWithContent and inherits its fields.

File Suffix and Directory Location 

DataWeaveResource components have the suffix .dwl and are stored in the dw folder.

Version 

Introduced in API version 58.0.

Special Access Rules 

There are no additional access requirements that are specific to this type.

Fields 

apiVersion 

  • Type: double
  • Required: Yes
  • Description: Required.

isGlobal 

  • Type: boolean
  • Required: No
  • Description: When set to true, the generated DataWeaveScriptResource class is global.

isProtected 

  • Type: boolean
  • Required: No
  • Description: Not used.

Declarative Metadata Sample Definition 

The following is an example of a DataWeaveResource component.

csvToContacts.dwl

1%dw 2.0
2input records application/csv
3output application/apex
4---
5records map(record) -> {
6 FirstName: record.first_name,
7 LastName: record.last_name,
8 Email: record.email
9} as Object {class: "Contact"}

csvToContacts.dwl-meta.xml

1<?xml version="1.0" encoding="UTF-8"?>
2<DataWeaveResource xmlns="http://soap.sforce.com/2006/04/metadata">
3    <apiVersion>58.0</apiVersion>
4    <isGlobal>true</isGlobal>
5</DataWeaveResource>

The following is an example package.xml that references the csvToContacts definition.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package
3      xmlns="http://soap.sforce.com/2006/04/metadata">
4      <types>
5            <members>csvToContacts</members>
6            <name>DataWeaveResource</name>
7      </types>
8      <version>58.0</version>
9</Package>

Wildcard Support in the Manifest File 

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.