---
schema_version: "1"
id: c3f3cea0af5f3f2b38501dc7c2045e4f77e787c04e86dd12b70b7205963627b9
title: Using Lookup Tables in DataWeave
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/partner-manager/latest/lookup-tables-dataweave.md
canonical_url: https://docs.mulesoft.com/partner-manager/latest/lookup-tables-dataweave
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2b1518931b006c3d62fba869f5282b18839c817b12649edd35194fc5e9b8f516
description: MuleSoft Documentation Site
release: 2.x
latest: true
---
---
product: Partner Manager
version: 2.x
is-latest-version: true
---

# Using Lookup Tables in DataWeave

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

Use DataWeave lookup utility functions to retrieve values from Partner Manager lookup tables during
map execution.

To call lookup tables from DataWeave, import the lookup utilities module:

```dwl
import * from modules::b2blookuputils
```

## Function Compatibility by Lookup Table Type

Lookup functions are type-specific and can’t be used interchangeably.

<table><colgroup><col> <col></colgroup><thead><tr><th>Function</th><th>Supported table type</th></tr></thead><tbody><tr><td><p><code>b2bCompositeKeyLookup</code></p></td><td><p>Composite Key Lookup only</p></td></tr><tr><td><p><code>b2bCrossReferenceLookup</code></p></td><td><p>Cross-Reference Lookup only</p></td></tr><tr><td><p><code>b2bGenericLookup</code></p></td><td><p>Generic-enabled tables only</p></td></tr><tr><td><p><code>b2bGenericLookupWithFilter</code></p></td><td><p>Generic-enabled tables only</p></td></tr></tbody></table>

> [!IMPORTANT] If a function is called with an unsupported table type, the lookup call fails.

## Composite Key Lookup

Function: `b2bCompositeKeyLookup(tableName, lookupObject, failIfNoMatchFound)`

Use this function only with **Composite Key Lookup** table types.

### Parameters

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><p><code>tableName</code></p></td><td><p>String</p></td><td><p>Yes</p></td><td><p>Lookup table name.</p></td></tr><tr><td><p><code>lookupObject</code></p></td><td><p>Object</p></td><td><p>Yes</p></td><td><p>Key-value pairs where each key is a table column name and each value is the value to match.</p></td></tr><tr><td><p><code>failIfNoMatchFound</code></p></td><td><p>Boolean (default <code>true</code>)</p></td><td><p>No</p></td><td><p>If <code>false</code>, the function returns empty data when no match is found.</p></td></tr></tbody></table>

### Response

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>status</code></p></td><td><p>String</p></td><td><p>Lookup operation status.</p></td></tr><tr><td><p><code>errorMessage</code></p></td><td><p>String</p></td><td><p>Error details when the operation fails.</p></td></tr><tr><td><p><code>data</code></p></td><td><p>Object</p></td><td><p>Matching row data.</p></td></tr></tbody></table>

Example:

```dwl
%dw 2.0
output application/json
import * from modules::b2blookuputils
---
b2bCompositeKeyLookup(
  "B2B-Customer-Order-Profile",
  {"PARTNER_ID": "PARTNER_001", "CUSTOMER_NAME": "ACME_RETAIL"},
  true
)
```

## Cross-Reference Lookup

Function: `b2bCrossReferenceLookup(tableName, columnName, columnValue, failIfNoMatchFound)`

Use this function only with **Cross-Reference Lookup** table types.

### Parameters

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><p><code>tableName</code></p></td><td><p>String</p></td><td><p>Yes</p></td><td><p>Lookup table name.</p></td></tr><tr><td><p><code>columnName</code></p></td><td><p>String</p></td><td><p>Yes</p></td><td><p>Key column name.</p></td></tr><tr><td><p><code>columnValue</code></p></td><td><p>String</p></td><td><p>Yes</p></td><td><p>Value to search in the key column.</p></td></tr><tr><td><p><code>failIfNoMatchFound</code></p></td><td><p>Boolean (default <code>true</code>)</p></td><td><p>No</p></td><td><p>If <code>false</code>, the function returns empty data when no match is found.</p></td></tr></tbody></table>

### Response

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>status</code></p></td><td><p>String</p></td><td><p>Lookup operation status.</p></td></tr><tr><td><p><code>errorMessage</code></p></td><td><p>String</p></td><td><p>Error details when the operation fails.</p></td></tr><tr><td><p><code>data</code></p></td><td><p>Object</p></td><td><p>Matching row data.</p></td></tr></tbody></table>

Example:

```dwl
%dw 2.0
output application/json
import * from modules::b2blookuputils
---
b2bCrossReferenceLookup("Item_Code_Mapping", "Internal_SKU", "SKU-5520", true)
```

## Generic Lookup

Function: `b2bGenericLookup(tableName, failIfNoMatchFound)`

Use this function only with tables where generic lookup is enabled.

### Parameters

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><p><code>tableName</code></p></td><td><p>String</p></td><td><p>Yes</p></td><td><p>Lookup table name.</p></td></tr><tr><td><p><code>failIfNoMatchFound</code></p></td><td><p>Boolean (default <code>true</code>)</p></td><td><p>No</p></td><td><p>If <code>false</code>, the function returns empty data when no match is found.</p></td></tr></tbody></table>

### Response

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>status</code></p></td><td><p>String</p></td><td><p>Lookup operation status.</p></td></tr><tr><td><p><code>errorMessage</code></p></td><td><p>String</p></td><td><p>Error details when the operation fails.</p></td></tr><tr><td><p><code>data</code></p></td><td><p>Array&lt;Object&gt;</p></td><td><p>Entire table data.</p></td></tr></tbody></table>

Example:

```dwl
%dw 2.0
output application/json
import * from modules::b2blookuputils
---
b2bGenericLookup("Payment_Terms_Mapping", true)
```

## Generic Lookup with Filter

Function: `b2bGenericLookupWithFilter(tableName, lookupObject, failIfNoMatchFound)`

Use this function only with tables where generic lookup is enabled.

### Parameters

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><p><code>tableName</code></p></td><td><p>String</p></td><td><p>Yes</p></td><td><p>Lookup table name.</p></td></tr><tr><td><p><code>lookupObject</code></p></td><td><p>Object</p></td><td><p>Yes</p></td><td><p>Key-value pairs used as filters.</p></td></tr><tr><td><p><code>failIfNoMatchFound</code></p></td><td><p>Boolean (default <code>true</code>)</p></td><td><p>No</p></td><td><p>If <code>false</code>, the function returns empty data when no match is found.</p></td></tr></tbody></table>

### Response

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>status</code></p></td><td><p>String</p></td><td><p>Lookup operation status.</p></td></tr><tr><td><p><code>errorMessage</code></p></td><td><p>String</p></td><td><p>Error details when the operation fails.</p></td></tr><tr><td><p><code>data</code></p></td><td><p>Array&lt;Object&gt;</p></td><td><p>One or more rows matching the provided filters.</p></td></tr></tbody></table>

Example:

```dwl
%dw 2.0
output application/json
import * from modules::b2blookuputils
---
b2bGenericLookupWithFilter(
  "Payment_Terms_Mapping",
  {"Internal_Terms_Code": "NET30", "Salesforce_Payment_Term": "Net 30"},
  true
)
```

> [!TIP] If a transformation requires multiple lookups from the same table, retrieve table data once
> with `b2bGenericLookup` and then filter locally in DataWeave.

For lookup table concepts and type selection guidance, see
[Configuring and Managing Lookup Tables](https://docs.mulesoft.com/partner-manager/latest/lookup-tables-overview).
