---
schema_version: "1"
id: 4df6b66b37e02425e211d644d827e21eae8964bbfe3c9f76171d3feea0c05f0e
title: Creating Reference Maps for Message Types
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/partner-manager/latest/create-reference-map.md
canonical_url: https://docs.mulesoft.com/partner-manager/latest/create-reference-map
source_site: docs.mulesoft.com
content_type: documentation
content_hash: b4f88b2668d94947ee235828fa4e021b21b4102df675e82616617a13c0b70bb6
description: MuleSoft Documentation Site
release: 2.x
latest: true
---
---
product: Partner Manager
version: 2.x
is-latest-version: true
---

# Creating Reference Maps for Message Types

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

When you create a new Source at Host or Receive from Partners message type with a CSV, JSON, or XML
format, you must associate the message type with a DataWeave reference map. This is optional for
Receive from Partners message types with an EDFIACT or X12 format. Reference maps can include custom
message attributes that are extracted from the message payloads at runtime. The extracted attributes
are visible in the payload and are available for searching and tracking.

If the definition for the message type includes an uploaded schema, the input of the reference map
is the payload that follows the schema.

The output of the reference map contains the following fields:

<table><colgroup><col> <col> <col></colgroup><tbody><tr><td><p><strong>Field</strong></p></td><td><p><strong>Description</strong></p></td><td><p><strong>Required or Optional</strong></p></td></tr><tr><td><p>partnerReferenceId</p></td><td><p>Identifier that uniquely identifies the partner</p></td><td><div><div><p>Required for:</p></div><div><ul><li><p>All Source at Host message types</p></li><li><p>Receive from Partners message types with a CSV. JSON, or XML format</p></li></ul></div><div><p>You can hardcode this value as a static value, depending on your data processing and routing needs.</p></div></div></td></tr><tr><td><p>hostReferenceId</p></td><td><p>Identifier that uniquely identifies the host</p></td><td><div><div><ul><li><p>Required for:</p><div><ul><li><p>Receive from Partners message types with a CSV, JSON, or XML format</p></li></ul></div></li><li><p>Optional for:</p><div><ul><li><p>Receive from Partners message types formatted with an EDIFACT or X12 format</p></li><li><p>All Source at Host message types</p></li></ul></div></li></ul></div><div><p>You can hardcode this value as a static value, depending on your data processing and routing needs.</p></div><div><div data-type="NOTE">The JSON schema allows <code>hostReferenceId</code> to be null because it’s shared across message types. For Receive from Partners message types that use JSON, CSV, or XML, <code>hostReferenceId</code> is still required.</div></div></div></td></tr><tr><td><p>businessDocumentKey.</p></td><td><p>Key reference value, such as <code>Order Number</code> or <code>Invoice number</code></p></td><td><p>Optional</p></td></tr><tr><td><p>customAttributes</p></td><td><div><div><p>Array of custom message attributes to extract from the payload. You can specify up to 100 custom message attributes in a given environment and can make up to 25 of them searchable.<br><br>When specifying a custom message attribute, configure the following fields in the reference map:</p></div><div><ul><li><p>alias</p><div><p>Alias that uniquely identifies a pre-configured custom message attribute configuration. The aliases in the reference map must match the message type’s attribute definitions. If the map contains aliases that don’t exist, creating or updating the message type fails.</p></div></li><li><p>values</p><div><p>An array of values, such as order numbers or invoice numbers.<br><br>Use an array of strings, even if there is only one attribute to extract. Using an array enables support for transactions with one-to-many relationships, such as transactions in which one shipment notice includes multiple purchase order numbers.</p></div></li></ul></div></div></td><td><div><div><p>Optional</p></div></div></td></tr></tbody></table>

The output of a reference map must conform to this validation schema:

%dw 2.0 output application/json
---

{ "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "title": "Root", "type":
"object",

    "properties": {
    	"partnerReferenceId": {
    		"type": "string",
    		"default": "",
    		"pattern": "^.\*$"
    	},
    	"hostReferenceId": {
    		"type": \["string", "null"\],
    		"default": "",
    		"pattern": "^.\*$"
    	},
    	"businessDocumentKey": {
    		"type": \["string", "null"\],
    		"default": "",
    		"pattern": "^.\*$"
    	},
    	"customAttributes": {
    		"type": "array",
    		"default": \[\],
    		"items":{
    			"type": "object",
    			"required": \[
    				"alias",
    				"values"
    			\],
    			"properties": {
    				"alias": {
    					"type": "string",
    					"default": "",
    					"pattern": "^.\*$"
    				},
    				"values": {
    					"type": "array",
    					"default": \[\],
    					"items":{
    						"type": "string",
    						"default": "",
    						"pattern": "^.\*$"
    					}
    				}
    			}
    		}

    	}
    }

}

If the output of a reference map does not conform to the validation schema, the custom message
attributes won’t appear in the Partner Manager GUI. To ensure that the output of a reference map
conforms to the validation schema, you can add an Anypoint Connector for X12 EDI (X12 Connector)
**Validate schema** operation to your MuleSoft app, as shown in these Exchange examples:

- [B2B/EDI: Order to Cash - Mapping Examples](https://anypoint.mulesoft.com/exchange/com.mulesoft.muleesb.modules/b2b-order-to-cash-mapping/)

- [B2B/EDI: Procure to Pay Mapping Examples](https://www.mulesoft.com/exchange/com.mulesoft.muleesb.modules/b2b-procure-to-pay-mappings/)

When you create a reference map, you can access other source message attributes in those maps. For
information, see [Accessing Source Message Attributes](https://docs.mulesoft.com/partner-manager/latest/access-source-message-attributes).

## Example Map for a Receive from Partners Message Type

The following map transforms a partner’s inbound X12 payload. The map contains a business document
key and two custom message attributes:

- The value of the business document key is
  `payload.TransactionSets.v004010."855".Heading."020_BAK".BAK03[0]`.

- The value of the `purchaseOrderNumber` custom message attribute is
  `payload.TransactionSets.v004010."855".Heading."020_BAK".BAK03[0]`.

- The value of the `vendorSalesOrderNumber` custom message attribute is
  `payload.TransactionSets.v004010."855".Heading."020_BAK".BAK08[0]`.

The input to the map looks like this:

%dw 2.0 output application/json { businessDocumentKey:
payload.TransactionSets.v004010."855".Heading."020\_BAK".BAK03\[0\] default "", customAttributes: \[
{ alias: "purchaseOrderNumber", values:
\[payload.TransactionSets.v004010."855".Heading."020\_BAK".BAK03\[0\]\] }, { alias:
"vendorSalesOrderNumber", values:
\[payload.TransactionSets.v004010."855".Heading."020\_BAK".BAK08\[0\]\] } \] }

The generated output of the map looks like this:

{ "businessDocumentKey": "ORDER-70010", "customAttributes": \[ { "alias": "purchaseOrderNumber",
"values": \[ "ORDER-70010" \] }, { "alias": "vendorSalesOrderNumber", "values": \[ "SO-5100803142"
\] } \] }

## Example Map for a Source at Host Message Type

The following map transforms the outbound JSON or XML payload from the backend. The map contains the
partner reference ID, host reference Id, business document key, and three custom attributes:

- The value of the partner reference ID is `payload.Header.CustomerName`.

- The value of the host reference ID is `payload.Invoice.Header.LineOfBusiness`.

- The value of the business document key is `payload.Invoice.Header.InvoiceNumber`.

- The value of the `invoiceNumber` custom attribute is `payload.Invoice.Header.InvoiceNumber`.

- The value of the `purchaseOrderNumber` custom message attribute is
  `payload.Invoice.Header.PurchaseOrderNumber`.

- The value of the `invoiceAmount` custom message attribute is
  `payload.Invoice.Header.TotalInvoiceAmt`.

The input to the map looks like this:

%dw 2.0 output application/json
---

{ partnerReferenceId: payload.Invoice.Header.CustomerName, hostReferenceId:
payload.Invoice.Header.LineOfBusiness default "MYTHICAL", businessDocumentKey:
payload.Invoice.Header.InvoiceNumber, customAttributes: \[ { alias: "invoiceNumber", values:
\[payload.Invoice.Header.InvoiceNumber default "UNKNOWN"\] }, { alias: "purchaseOrderNumber",
values: \[payload.Invoice.Header.PurchaseOrderNumber default "UNKNOWN"\] }, { alias:
"invoiceAmount", values: \[ "\\$ " ++ payload.Invoice.Header.TotalInvoiceAmt default "UNKNOWN"\] }
\] }

The generated output of the map looks like this:

{ "partnerReferenceId": "ALPHA-CAN", "hostReferenceId": "Mythical-MG", "businessDocumentKey":
"INV97750061", "customAttributes": \[ { "alias": "invoiceNumber", "values": \[ "INV97750061" \] }, {
"alias": "purchaseOrderNumber", "values": \[ "ORD3893988" \] }, { "alias": "invoiceAmount",
"values": \[ "$ 3756.24" \] } \] }

## Exchange Examples of DataWeave Maps

For examples of DataWeave maps on Exchange that include custom message attributes, see:

- [B2B/EDI: Order to Cash - Mapping Examples](https://anypoint.mulesoft.com/exchange/com.mulesoft.muleesb.modules/b2b-order-to-cash-mapping/)

- [B2B/EDI: Procure to Pay Mapping Examples](https://www.mulesoft.com/exchange/com.mulesoft.muleesb.modules/b2b-procure-to-pay-mappings/)

## See Also

- [Creating a Message Type](https://docs.mulesoft.com/partner-manager/latest/partner-manager-create-message-type)

- [Modifying Message Type Settings](https://docs.mulesoft.com/partner-manager/latest/modify-message-type-settings)

- [Using Custom Message Attributes with Message Types](https://docs.mulesoft.com/partner-manager/latest/use-custom-attributes)
