# Data Transformation Addon

The purpose of this block is to produce a transformed result based on the data from the source

and filters blocks.

This block can be used in conjunction with pagination and filters for the

source block.

<figure><img src="/files/2pCeLNmBPEOaantuX6HN" alt=""><figcaption></figcaption></figure>

## Usage

As shown in the example below, dataTransformationAddon blocks should be placed after

documentsSourceAddon and filtersAddon blocks.

<figure><img src="/files/03rNvp3Xitz3Fz45YERO" alt=""><figcaption></figcaption></figure>

## Properties

| Property Name        | Description                                                                                                                            | Example                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Expression           | <p>A custom JavaScript</p><p>function that transforms</p><p>the existing source data</p><p>and returns it in a</p><p>custom format</p> | <p><code>function main(documents){</code></p><p><code>let sum = 0;</code></p><p><code>for(let i=0; i< documents.length; i++) {</code></p><p><code>sum+=</code></p><p><code>documents\[i].document.credentialSubject\[0].fiel</code></p><p><code>d0 +</code></p><p><code>d1;</code></p><p><code>documents\[i].document.credentialSubject\[0].fiel</code></p><p><code>}</code></p><p><code>return {</code></p><p><code>sum</code></p><p><code>}</code></p><p><code>}</code></p><p><code>done(main(documents));</code></p> |
| hideWhenDiscontinued | Check if the button should be hidden when policy is discontinued                                                                       | Checked/Unchecked                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

## API

The API for the dataTransformationAddon uses the GET method

Example response to a GET request that returns the sum of 2 fields in a custom format:

```
{
"sum": 10
}
```

The request can be fulfilled through both endpoint

*`/api/v1/policies/{policyId}/blocks/{blockId}`*

and

*`/api/v1/policies/{policyId}/tag/{blockTag}/blocks`*


---

# 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://guardian.hedera.com/guardian-dev/guardian/standard-registry/policies/policy-creation/introduction/data-transformation-addon.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.
