# Triggers

> The four triggers in detail. A record is created, a record is changed, a condition holds and on a schedule. When each one fires, what it hands to the steps, and how often nexxus checks.

The trigger decides when an automation looks at your data. There are two families. **Record triggers** react to a change the moment it is saved. **Checking triggers** look at your data by themselves, every few minutes or at set times.

| Trigger | Family | Fires | Hands to the steps |
|---|---|---|---|
| <Ui>A record is created</Ui> | Record | once for every new record of the source | that one record |
| <Ui>A record is changed</Ui> | Record | on every change, or only on changes to the fields you name | that one record |
| <Ui>A condition holds</Ui> | Checking, every 5 minutes | when records start to match, or when a count reaches a threshold | the new matches, or the count |
| <Ui>On a schedule</Ui> | Checking, at the times you set | at each point in time | the matching records of the source, or nothing |

What a trigger hands to the steps decides what the steps can do. Placeholders such as `{{record.title}}` and the step <Ui>If / else</Ui> need records. A count offers the placeholder `{{count}}` instead.

## A record is created

Fires once for every record that is created in the source, by a person, by the AI Assistant or by another automation. The condition under <Ui>Only if</Ui> is checked when the run starts, a few seconds later; a record that does not match is left alone.

Records that arrive through an import do not trigger, and neither does a change that is rolled back.

## A record is changed

Fires on every saved change to a record of the source. Under <Ui>Only on changes to</Ui> you can name fields; the automation then only fires when at least one of them changed. Left empty, it shows <Ui>any field</Ui> and fires on every change.

<Screenshot src={shot_updated} alt="The trigger A record is changed with the data source Projekte and the field Ampel under Only on changes to" caption="Fires only when the traffic light (Ampel) of a project changes, not when someone edits its description." />

To react to a field **changing to** a certain value, combine both parts: the field under <Ui>Only on changes to</Ui>, and the value as a condition under <Ui>Only if</Ui>. "Status changes to Done" is the trigger with the field Status plus the condition "Status is Done". Without the field, the automation would fire again on every later edit of a record that is already done.

:::note[The test run counts at most]
For this trigger, the test run counts the records changed in the last 7 days. It cannot see which field changed back then, so it says <Ui>At most this often: the test run cannot see whether the field changed.</Ui>
:::

## A condition holds

nexxus checks the condition every 5 minutes, independently of who changed what. This is the trigger for states rather than events: "a risk is open and high", "more than three incidents are open", "a review date has passed". It also catches records that reach the state without anyone editing them, because a date has moved into the past.

Under <Ui>What triggers</Ui> you pick one of two modes.

**<Ui>every record that starts to match</Ui>.** The steps run for each record that matches now and did not match at the last check. A record that keeps matching does not fire again. Several new matches in the same check form one run, and each person gets one notification listing them.

**<Ui>the count reaches a threshold</Ui>.** nexxus counts the matching records and compares the count with your threshold under <Ui>When the count is</Ui>: <Ui>more than</Ui>, <Ui>at least</Ui>, <Ui>less than</Ui>, <Ui>at most</Ui> or <Ui>exactly</Ui>. The steps run once when the threshold is reached, with the placeholder `{{count}}`. Two options:

- <Ui>Also run when it stops holding</Ui>: the steps run a second time when the count drops back, so people know the situation is over.
- <Ui>Repeat every … days</Ui>: as long as the threshold stays reached, the steps run again after this many days, at most 30. Empty means no repetition.

<Screenshot src={shot_count} alt="The trigger A condition holds in the mode the count reaches a threshold: more than 3, also run when it stops holding, repeat every 7 days" caption="More than 3 open incidents: one notification when it happens, a reminder every 7 days while it lasts, and one when it is over." />

**What already matches when you save does not trigger**, only what changes afterwards. The first check after saving takes stock. The same happens when you switch an automation off and on again: it does not catch up on what happened in between.

A condition that matches more than 1,000 records stops with <Ui>Die Bedingung trifft auf mehr als 1.000 Datensätze zu. Bitte enger fassen oder „Anzahl“ statt „jeder Datensatz“ wählen.</Ui> (the condition matches more than 1,000 records; narrow it or count instead). Counting has no such limit.

## On a schedule

Runs at the times you set, in the tenant's time zone. The editor shows the zone below the schedule and lists the next runs, so you can check the result before saving.

| Kind | Set | Example |
|---|---|---|
| <Ui>Interval</Ui> | every so many minutes, hours or days, from a start time; at least every 15 minutes | every 2 hours from 07:00 |
| <Ui>Daily</Ui> | a time | every day at 07:30 |
| <Ui>Weekly</Ui> | every so many weeks, the weekdays and a time | every Monday at 08:00 |
| <Ui>Monthly</Ui> | a day of the month, or a position and a weekday, and a time | on the last Friday at 16:00 |
| <Ui>Custom expression</Ui> | a cron expression with six fields in Spring format: second, minute, hour, day, month, weekday | `0 0 8 * * MON-FRI` |

<Screenshot src={shot_schedule} alt="The trigger On a schedule: weekly on Monday at 08:00 with the source ISMS-Maßnahmen and the next five runs" caption="Every Monday at 08:00. In short and Next runs show what you set; the tenant's time zone is below." />

The data source is optional here, labelled <Ui>For every record from (optional)</Ui>.

- **With a source**, each run looks for the records that match the condition at that moment, and the steps run for all of them in one run. A weekly report of measures that are due is this case. Each person gets one notification listing the records. When no record matches, nothing runs. A schedule handles at most 1,000 records per run.
- **Without a source**, the steps run once per point in time (<Ui>none, once per date</Ui>), with no record. A reminder such as "every Monday, look at the open incidents" is this case. Without records, placeholders like `{{record.title}}` and the step <Ui>If / else</Ui> are not available.

## How often nexxus looks

| Job | Every | Serves |
|---|---|---|
| `AUTOMATION_EVENTS` | 2 seconds | <Ui>A record is created</Ui>, <Ui>A record is changed</Ui> |
| `AUTOMATIONS` | 60 seconds | <Ui>On a schedule</Ui> (at the minute), <Ui>A condition holds</Ui> (every 5 minutes) |

Both jobs are off in a new installation until a superadmin switches them on. See [Run automations for the tenant](/automations/administration/#switch-on-the-cron-jobs).

## Next steps

<CardGrid>
  <LinkCard title="Conditions" href="/automations/conditions/" description="And, or, not, groups and dates relative to today." />
  <LinkCard title="Steps and placeholders" href="/automations/steps/" description="What the steps do with the records a trigger hands over." />
</CardGrid>