# Functions

## Overview

Functions are used on the platform to define dynamic actions in your application. They are scripts with input parameters which in turn can be called in scripts. The Function Designer provides an interface for creating and managing functions.

On the start page of the Designer, all available functions are listed. In addition, new functions can be created. In the context menu of an instance these actions can be performed:

* **Clone**: an exact copy of this instance is created and added to the list
* **Used By**: Listed all class, function, layout, selection, workflow, template who use this instance
* **Delete**: delete this instance

![Function Designer](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MW5-3CWkqvLwnkSpDs4%2F-MW53ZpQWfFLX19XA6Lw%2FFunctions-Overview.png?alt=media\&token=7be21c5d-5017-49db-87c5-e5e8319af8ec)

## Settings

The interface of the function settings are divided into three sections. In **General** the function name and description of the function are entered. In addition, a unique key must be assigned. With this key the function can be called at another place.\
In the **Function** section, the underlying script can be created or opened. How scripts are built you can [see in Scripting](https://docs.tivity.one/building-an-application/execution/scripting). The return type of the function is also set at this point. \
Finally, under **Parameter** the input parameters can be configured. How to add and configure parameters is described in the next chapter.

![Function settings](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MW5-3CWkqvLwnkSpDs4%2F-MW59cxv8nHQKOWhh08G%2FFunctions-Settings.png?alt=media\&token=d6b5c38e-1427-492c-a2e3-b1d9ac306fc7)

{% hint style="info" %}
The **Key** property is compulsory when creating a function.
{% endhint %}

## Parameter

It is possible to add parameters to a function. These are queried in the interface when the function is executed.

![Parameter configuration](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MW5-3CWkqvLwnkSpDs4%2F-MW5HQnnB_UHJK_Lc652%2FFunctions-Parameter.png?alt=media\&token=5aec10fc-a84c-49ec-b95a-14623a9a40de)

The **Key** is the parameter name with which you can access it in the script context. The **Type**  property defines the layout control with which the parameter query will be displayed later during execution. If **Required** is enabled, an input is forced. The **Actions** offered deleting and moving (changing the order) of a parameter.

{% hint style="info" %}
&#x20;The **Key** property is compulsory when creating a parameter.
{% endhint %}

## Executing

After the function is created and a script is built, this function is available to the app. In each script in the different contexts, this function can now be called. These includes Workflow Designer, Template Designer and of course in another function.\
To execute the function in the script, the action *ExecuteFunction* is offered. When this action is added in the designer, you can choose from a list of available functions.

![ExecuteFunction action](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MYApYyVZyZ4XyLDA6iX%2F-MYAwvVptFk9zjctqhgA%2FFunctions-ExecFuncAction.png?alt=media\&token=65c44fd4-50f5-4c24-b21f-2d5ab5d1b6e8)
