> For the complete documentation index, see [llms.txt](https://docs.heisenware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.heisenware.com/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/functions.md).

# Functions

Functions are the key building blocks for any kind of functionality within Heisenware. They can perform a wide range of actions, including:&#x20;

* Fetching and sending data
* Processing and manipulating data
* Creating objects
* Creating and managing database tables

## Types

There are different types of functions with different properties and origins.&#x20;

### Static functions

Static functions are standard and don't have any context or state, meaning that each of these functions is independent and does not rely on any previous information.&#x20;

### Object functions

Object functions, also referred to as member functions, are the actions an [object](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/objects-and-instances.md) is able to perform. As they always belong to a specific object, they have context and can include previous information. In order to use an object function, you need to create an object using a `create` function first.&#x20;

### Custom functions

Custom functions can perform any action and generally behave like either static or object functions. They can be used by integrating custom code with the [code adapter](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/integration/calling-custom-code.md). This implies that these functions are not inherently part of the App Builder, but rather extend its functionality.

## Basic structure

Typically, a function consists of one or more [input arguments](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/functions/inputs.md), a [trigger](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/functions/trigger.md), and an [output](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/functions/output.md). In some cases, for example when using a read function to fetch sensor data, the function does not need an input argument to work properly.

<div align="left"><figure><img src="/files/wuMV8tcL72FPKXCfunkM" alt=""><figcaption><p>A merge objects function with two inputs, trigger and output</p></figcaption></figure></div>

{% hint style="info" %}
The structure of a low-code function in Heisenware corresponds to the structure of coded software functions. This means that almost any function can be mapped and made available via low-code.
{% endhint %}

## Status

Each function has a status indicator showing its condition. The status indicator, a colored circle, can be found right next to the function handler. The status can be:

* <mark style="color:green;">**Green**</mark>: everything okay
* <mark style="color:red;">**Red**</mark>: an exception or error has occurred
* **Gray**: function not available or offline
* <mark style="color:blue;">**Blue**</mark>: function execution takes very long to finish (> 2 seconds)

Hover above the indicator to get details about the function's condition.

## Documentation

Built-in functions provide documentation. Hover above the function name to read it.

<div align="left"><figure><img src="/files/7Fu7a2YZVsUSKBnZ2DBH" alt=""><figcaption><p>Function documentation</p></figcaption></figure></div>

Functions added via the Code Adapter can automatically provide documentation if the original code has been documented properly.

## Extensions

Extensions allow on-the-fly data processing for function output. There are four extensions:

* [Modifier](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/function-extensions/modifier.md): Allows modifying data with JavaScript and JSONata.
* [Filter](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/function-extensions/filter.md): Enables condition-based interruption or continuation of flows using JavaScript.
* [Recorder](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-and-file-storage/internal-influxdb.md): Records data in InfluxDB.
* [Error Handler](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/function-extensions/error-handler.md): Enables processing of exceptions thrown by a function.

## Working with functions

### Adding functions

To add a function to an app:

1. Search the function in the functions panel.
2. Drag and drop it to the desired section within the logic board.

That's it. You can now start to configure and link the function.

### Linking functions

Each part of a function, including extensions, can be configured and linked separately, allowing for maximum flexibility and almost limitless data processing options. Linking possibilities include:

* Backend to frontend.
  * Function to [widget ](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/ui-elements.md#widgets)and vice versa.
  * Function to page or subpage.
* Backend to backend.
  * Function to function.
  * Function with same function.
  * Function to file.

To create a link, drag and drop the part of a function onto the item you want to link it to. When linking to the frontend, you first select the [frontend widget ](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/ui-elements.md)and then drag and drop the relevant part of the function onto it.

To see existing links, hover above one part of a function. Any existing link to and from this part is indicated by a light shadow within another function. Links to widgets are indicated by a border around the widget.

<div align="left"><figure><img src="/files/mgJhGHWp8tFwbvYbUO2N" alt=""><figcaption><p>Link indication</p></figcaption></figure></div>

### Flows

Flows consist of chained functions where [output](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/functions/output.md) data or [modified](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/function-extensions/modifier.md) data serves as an [input argument](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/functions/inputs.md) for subsequent functions. The creation of flows involves linking functions together. Flows are typically triggered by the update or change of output data, automatically initiating a sequence of connected functions. [Filters](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/function-extensions/filter.md) within flows act as switches, altering the flow's direction based on the output data. They can interrupt or continue flows in a specific direction depending on the specified conditions.

### Commenting functions

When creating apps with many functions, it can be helpful to comment functions so that it is easier to understand what action a particular function performs. To comment a function:

1. Right-click on the function name.
2. Click `Comment` in the context menu.
3. Add a comment.

<div align="left"><figure><img src="/files/YIQtDvB0v2UVFyvAjC1V" alt=""><figcaption><p>A commented function</p></figcaption></figure></div>

To change a comment, click on the comment and start typing.

### Moving functions

To move a function to a new position, drag and drop it with its handle icon. You can only move functions within the same section. The position of a function does not affect its functionality and links.

### Deleting functions

To delete a function:

1. Right-click on the function name.
2. Click `Delete` in the context menu.

{% hint style="warning" %}
When deleting a function, its links and configuration will be deleted with it. This action can't be undone.&#x20;
{% endhint %}

## Connect function with UI

Backend and frontend communicate by connecting function [input](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-and-file-storage/internal-influxdb.md#input), [trigger ](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/functions/trigger.md)or [output ](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/functions/output.md)with [UI elements](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/ui-elements.md). Through this connection, functions can both set and receive widget properties. The link between a widget and the part of the function determines the direction of data exchange, specifying which data or events are transferred.


---

# 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 dynamically by asking a question.

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

```
GET https://docs.heisenware.com/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/functions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
