# Using a cross-reference lookup in field transformations

## Introduction

**Cross-reference lookups** can be applied as a [field mapping transformation](https://doc.wearepatchworks.com/product-documentation/process-flows/cross-reference-lookups/using-a-cross-reference-lookup-in-field-transformations), using the `map` function. The steps below show how this is achieved. &#x20;

## The steps

<details>

<summary><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpLMO12yvTCxi9PorCt53%2Ficons8-film.svg?alt=media&#x26;token=e59864bc-2d97-4f98-966c-a083c18e60db" alt="" data-size="line"> Show me</summary>

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FVzximxYSrtz6GZa1qQH7%2Fdemo%20add%20transform%20with%20lookup.gif?alt=media\&token=96ae8b23-5992-442e-803a-6766ab90630a)

</details>

**Step 1**\
Log into the Patchworks dashboard, then select **process flows** and open the process flow that you want to update.

**Step 2**\
Access settings for the [map shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/map-shape) so you can see existing mapping rules - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FdwHmyE9iXmB2WQSkY6ZU%2Flookup%20transform%201.png?alt=media&#x26;token=3d0d358b-e4d5-4751-b1e6-1a234d0a9914" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 3**\
Find the mapping rule that you want to update with a transformation, and click the **transform** button:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FwtJS7UubAYJKlxazCLYS%2Flookup%20transform%202.png?alt=media&#x26;token=beba6ce6-a15c-4377-9537-bc9bb9bb4fad" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 4**\
Any existing transformations for this mapping rule are shown. Click the **add transform** button:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FxR8NQIPDHubArcfcb6CT%2Flookup%20transform%203.png?alt=media&#x26;token=3f2e30c2-d5cf-4d92-a23e-c33c75facb10" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 5**\
Click in the **name** field to activate a dropdown list of all [available transform functions](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/map-shape/working-with-field-transformations/available-transform-functions), then select the **map** function from the **other** section:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FgQan3xzGd5caC9bjBEUM%2Flookup%20transform%204.png?alt=media&#x26;token=3af73fca-2134-4473-9899-f5d8b581c9e8" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 6**\
Click in the **map** field to activate a dropdown list of available [cross-reference lookups](https://doc.wearepatchworks.com/product-documentation/process-flows/cross-reference-lookups/accessing-cross-reference-lookups), then select the lookup that you'd like to use. For our example, we'll use a lookup that we added previously which maps long-form colours to hex codes: &#x20;

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FXDiOXaKBquBcFOeqaIGg%2Flookup%20transform%205.png?alt=media&#x26;token=61605219-d89e-478f-9d1e-97fb02c7ed59" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 7**\
Use the **direction** field to choose whether this conversion should take place form **left to right** or **right to left**:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FxZSFPYCIdz5EtYA7fAP7%2Flookup%20transform%206.png?alt=media&#x26;token=654abdcb-3037-4cfa-8c35-3010d06dbdb0" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 8**\
Use the **match type** field to choose how data to be transformed should be matched:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FrQuvuKrm1r4XmGeHlkqO%2Flookup%20transform%207.png?alt=media&#x26;token=d9cc4c02-028a-4fcc-b69a-fe0a60138def" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 9**\
Use the **output type** field to choose the data type for the transformed value:&#x20;

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FFy3KfddWYRorx6PomzbK%2Flookup%20transform%208.png?alt=media&#x26;token=4cc060e3-87d0-4f9f-a167-70888aaa3b18" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 9**\
Click the **add field** button:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F07EykDC2P6aojIM8wel7%2Flookup%20transform%209.png?alt=media&#x26;token=8e947f7e-e314-4c37-adce-a2afed4fcd3c" alt="" width="563"><figcaption></figcaption></figure></div>

**.**..then confirm the **source** field to be transformed:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FPhqgzleHzRmBlw0rcztO%2Flookup%20transform%2010.png?alt=media&#x26;token=7bb349f6-05a5-4598-a90f-391d2accd324" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 9**\
Accept changes and the function is confirmed for the mapping rule:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FEKqbM3Ebg0jxB8FFb1d4%2Flookup%20transform%2011.png?alt=media&#x26;token=b4f16abe-45ea-4b2b-99cd-59ecb1a493fe" alt="" width="563"><figcaption></figcaption></figure></div>

At this point, the cross-reference lookup transformation is ready to use. When you save the map shape and run the process flow, your transformation is applied.

However, if required, you can add more transformation functions for a mapping rule - follow the steps above and choose the appropriate function in step 5.&#x20;

Looking at our example scenario, it's useful to add a **prefix** function to add a **#** character before any `colour` field values:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FZQlMaqPpMxigZryk3Vih%2Flookup%20transform%2011%20prefix%20c.png?alt=media&#x26;token=9fb7af82-a176-4235-9248-73a2adefbae0" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
To see how this second transform was added, check the video at the start of these steps.
{% endhint %}

{% hint style="warning" %}
If you add multiple functions, the sequence is important! Looking at our example above, we are transforming the colour field first (so long-form colour names are converted to hex codes) and once that is done, we apply a # (string) prefix to those values.
{% endhint %}

**Step 10**\
Now when your process flow runs, the transformations are applied:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FJAvU3MsH2qTnDuOxmlIR%2Flookup%20transform%2011%20prefix%20d.png?alt=media&#x26;token=bad4b602-1985-4272-a5bc-458395ea9f55" alt="" width="563"><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.wearepatchworks.com/product-documentation/process-flows/cross-reference-lookups/using-a-cross-reference-lookup-in-field-transformations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
