# Automations

Automations run logic automatically when a defined event happens. Use them to keep data consistent and reduce manual work.

## **What automations do**

An automation follows a simple pattern: when this happens, run this logic.

Use automations when the same action should happen every time the same event occurs.

Typical examples are:

* setting default values for new records
* recalculating dependent values after a change
* reacting when a record is deleted

If users should decide when logic runs, a button is usually the better choice.

## **Automation events in Ninox**

In the current UI, Ninox offers these automation events:

* **On create** runs when Ninox creates a record. Use it to assign an internal number, set defaults, or create related data. You can find it in the table settings.
* **On update** runs when a record changes. Use it to normalize input, update dependent fields, or keep related data in sync.
* **On delete** runs when Ninox deletes a record. Use it when other data or follow-up logic must react to that deletion.

{% hint style="info" %}
Use automations for logic that should always run in the background. Use buttons when users should stay in control.
{% endhint %}

## **Best practices**

Automations are powerful, but they can make an app harder to understand if too much logic runs automatically.

Use these rules:

* keep automation logic short
* avoid hidden side effects when possible
* test automations with real user workflows
* document important automatic behavior clearly
* use buttons instead of automations when users should decide

{% hint style="warning" %}
Be careful with automations that update data. They can trigger more write activity and make debugging harder.
{% endhint %}

Automation logic that writes data runs inside write transactions. Slow automation logic can delay other write actions.

Keep this in mind especially when an automation:

* updates many records
* calls external services
* runs large `select` queries

For more detail, see [Best practices and common pitfalls](/ninox-scripting/automate-your-workflows/best-practices-and-common-pitfalls.md).

## **Example uses**

Here are typical uses for each event:

* **On create** can set `today()`, assign the next invoice number, and set a default status.
* **On update** can refresh totals, standardize field values, or sync related records.
* **On delete** can react to record removal in related workflows.


---

# 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.ninox.com/ninox-scripting/automate-your-workflows/automations.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.
