> 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/eYCCpn9cCBKOYnZA6a8f/building-apps/data-processing/functions/trigger.md).

# Trigger

The trigger initiates a function to execute its action. To do this, the trigger listens for events. Events can be captured by users or programmatically.&#x20;

Jump to [explainer video](#explainer-video).

## Trigger events

The following events can serve as triggers:

* Application logic events
  * `change`, `update`, or becoming `true` of an input argument
  * `change`, `update`, or becoming `true` of an output
  * `change`, `update`, or becoming `true` of a modifier
* UI events
  * Click of a button
  * Loading of a page
  * Start of an app
    * once
    * periodic (every 0.1 seconds to once a day)
  * Stop of an app
* App Builder: Click on the trigger icon of the function

A single function can be associated with more than one trigger event. For instance, a function might be triggered when its input argument is updated or when a page is loaded.

<div align="left"><figure><img src="/files/PK2E6BvZVG1tmODZqN00" alt=""><figcaption><p>Two trigger events</p></figcaption></figure></div>

## Configuration

A trigger can be configured in different ways:

* **Via context menu**: Right-click on the trigger box
  * `App start`
  * `App stop`
* **Drag and drop of other items on a trigger**
  * `on page load`
  * on input `change`, `update`, `true`
  * on output `change`, `update`, `true`
  * on modifier `change`, `update`, `true`
* **Drag and drop of a trigger on a button**

To unlink an event from a trigger, click the `x` next to the trigger event.

## Sequential processing

To sequentially process an array of data, the trigger can be configured to execute the function for each value within the array individually, one by one. This type of function execution corresponds to a so-called loop in classic programming.&#x20;

To configure sequential processing of arrays:

1. Right-click on the trigger to open the context menu.
2. Hover above `Process One By One`.
3. Select the input argument of the function that contains the array.

To switch back to regular processing:&#x20;

1. Right-click on the trigger to open the context menu.
2. Select `Process Regularly`.

{% hint style="info" %}
**Example:** One prevalent use case for sequential processing is merging objects, where an array of objects contains objects to merge with another object. The following image illustrates a function where the trigger of the `mergeObjects` function is configured to `Process One By One` on argument one (`On arg 1`). As a result, both objects in the output contain the keys of both merged objects.
{% endhint %}

<div align="left"><figure><img src="/files/JpKc8hF20wbzrfFhkUMZ" alt=""><figcaption><p>Sequential processing of functions</p></figcaption></figure></div>

## Explainer video

{% embed url="<https://www.youtube.com/watch?v=5P0zLhaySGo>" %}


---

# 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:

```
GET https://docs.heisenware.com/~/changes/eYCCpn9cCBKOYnZA6a8f/building-apps/data-processing/functions/trigger.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.
