# Function Creation Process

Every function object has the following parameters:

* **Name:** This is the value that will appear in the selection in a Tag configuration. Here, you should use a descriptive name.
* **ID**: This technical reference can explicitly reference a function, as this ID is unique per DCP.
* **Description**: Feel free to describe your Function to better understand the motivation to this application later.
* **Javascript**: This is the actual function code that you will define

<figure><img src="/files/H7JLpaghk7uzqvDhfB7O" alt=""><figcaption></figcaption></figure>

As a function is referenced in a tag to process and return a value, you must define an input and output value. Use the following basic syntax, as any function must return a value.

{% hint style="warning" %}
Functions can only work with **one input**. Adding more variables in the tag edit view will concatenate the inputs into a single parameter.
{% endhint %}

{% code lineNumbers="true" %}

```javascript
async function(input){
  var processed_value = input+1;
  return processed_value;
}
```

{% endcode %}

### Transformation Functions

Any transformation function that runs server-side can fully support async features like \`await\` and \`promise\`.

Hence, if you intend to use async features, you must always declare the code to be async in the first line of code.

{% code lineNumbers="true" %}

```javascript
async function _(input) {
  // use await or promise if required
}
```

{% endcode %}

{% hint style="danger" %}
You can not use async features on client-side executed transformation functions, so the same transformation functions are not applicable to both client—and server-side tags.
{% endhint %}

### Workaround for multiple arguments

If you need multiple input arguments, a possible workaround is to use a delimiter to concatenate the different variables and then split the information within the function.

<figure><img src="/files/vZUmz4nSYoOPU4oxg2oo" alt=""><figcaption></figcaption></figure>

{% code title="Example Function Code" lineNumbers="true" %}

```javascript
function  hashed_id_sha256(args) {
    let params = args.split(':::');
    let id = params[0];
    let account = params[1];

    if (['abc','cdf'].includes(account)) {
        return this.tools.getSHA256(id);
    }

    return id;
}
```

{% endcode %}


---

# 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://docs.jentis.com/jentis-dcp-elements/functions-transformations/function-creation-process.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.
