> For the complete documentation index, see [llms.txt](https://docs.getmesa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getmesa.com/tools/custom-code/libraries/transform.md).

# Transform

vendor/Transform.js

## Transform()

The Transform utility can be used to define a relationship between objects from different sources. After defining the relationship, utility methods can be used to do things such as convert data from one source to another, allowing users to then post to API endpoints without additional data manipulation.

**Returns**

* `Void`

## map(mapping, payload)

Map a payload object to the desired output format based on a mapping array.

**Parameters**

| Name    | Type     | Description                                                                                  |   |
| ------- | -------- | -------------------------------------------------------------------------------------------- | - |
| mapping | `array`  | An array of key / value pair objects containing where key is source, value is `destination`. |   |
| payload | `object` | The payload passed into the Task.                                                            |   |

**Returns**

* `Void`

## convert(context, payload)

Convert fields defined in a Transform trigger. This method is called from the Transform trigger scaffolding script.

**Parameters**

| Name    | Type     | Description                                                                                                                      |   |
| ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- | - |
| context | `object` | The full context object passed into the Task. We use `context.source`, `context.trigger.metadata`, and `context.trigger.fields`. |   |
| payload | `object` | The payload passed into the Task.                                                                                                |   |

**Returns**

* `Void`

## safeSet(obj, key, value)

Proxy for \_.set with handling for line\_items\[].sku not captured in the array logic

**Parameters**

| Name  | Type     | Description |   |
| ----- | -------- | ----------- | - |
| obj   |          |             |   |
| key   | `string` |             |   |
| value |          |             |   |

**Returns**

* `Void`

## handleBracketStringSyntax(value)

For some reason "{{current\_item.fields\['Option 1']}}" doesn't work but "

{{current\_item.fields\[key]}}" does... this is a quick way to try to get it kind-of working

**Parameters**

| Name  | Type     | Description |   |
| ----- | -------- | ----------- | - |
| value | `string` |             |   |

**Returns**

* `string`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.getmesa.com/tools/custom-code/libraries/transform.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
