# Displaying Alerts

Canonical page: https://www.adaptabletools.com/docs/handbook-alerting

- Alerts fire when an **Alert Definition** matches grid activity — usually a cell edit or tick, but also row add/remove, schedules, or live observable rules
- AdapTable provides **seven** alert categories; most use an AdapTableQL **Rule** (Boolean, Observable, or Aggregation). **Scheduled** alerts use a **Schedule** instead
- Each alert has a **MessageType**, message text, optional **Alert Properties** (behaviours), and optional toast **Notifications** (message, command buttons, or a full form)
- Definitions are stored in Adaptable State; they can be scoped to [Layouts](https://www.adaptabletools.com/docs/handbook-layouts-extending/index.md) and suspended at run time

Alerts are one of the most popular features in AdapTable, and which add most value to run-time users.

You create an Alert Defintion which includes:

- the type of Alert
- the condition / rule that triggers it
- how it should look (message type and copy)
- what should happen when it fires (highlight, jump, notification, validation rollback, and more)

An Alert can be limited to specific layouts via [Layout Extensions](https://www.adaptabletools.com/docs/handbook-layouts-extending/index.md)

## Topics in this Section

| Topic                                                                                  | Description                                                               |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [Data Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-data-change/index.md)         | Boolean rules on cell changes with Column Scope                           |
| [Relative Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-relative-change/index.md) | `ANY_CHANGE`, `PERCENT_CHANGE`, and `ABSOLUTE_CHANGE` on the edited cell  |
| [Row Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-row-change/index.md)           | Rows added or removed; optional per-row boolean Rule                      |
| [Aggregation Alerts](https://www.adaptabletools.com/docs/handbook-alerting-aggregation/index.md)         | Boolean rules evaluated across many rows (limits-style analysis)          |
| [Observable Alerts](https://www.adaptabletools.com/docs/handbook-alerting-observables/index.md)          | Live history, time windows, and no-change detection                       |
| [Scheduled Alerts](https://www.adaptabletools.com/docs/handbook-alerting-schedule/index.md)              | One-off or recurring schedule (no Rule)                                   |
| [Validation Alerts](https://www.adaptabletools.com/docs/handbook-alerting-validation/index.md)           | Block invalid edits and roll back before commit                           |
| [Alert Message](https://www.adaptabletools.com/docs/handbook-alerting-message/index.md)                  | Headers, body text, tokens, templates, and message options                |
| [Alert Notification](https://www.adaptabletools.com/docs/handbook-alerting-notifications/index.md)       | Toast notifications, command buttons, and developer-defined Alert Forms   |
| [Alert Behaviours](https://www.adaptabletools.com/docs/handbook-alerting-behaviours/index.md)            | Highlight, jump, log, custom container, and related properties            |
| [Configuring Alerts](https://www.adaptabletools.com/docs/handbook-alerting-configuring/index.md)         | Alert Options, highlight durations, detection policy, batch consolidation |
| [Listening to Alerts](https://www.adaptabletools.com/docs/handbook-alerting-alert-fired-event/index.md)  | Alert Fired event and payload                                             |
| [Alerts Technical Reference](https://www.adaptabletools.com/docs/technical-reference-alerting/index.md)  | Alert Definitions, Options, State, and API                                |

## Alert definitions

Alert Definitions are configured in [Alert Initial State](https://www.adaptabletools.com/docs/technical-reference-alerting/index.md) or created at run time.

Each `AlertDefinition` object includes a number of properties including:

- **Name**
- **MessageType**, **MessageHeader** / **MessageText** (see [Alert Message](https://www.adaptabletools.com/docs/handbook-alerting-message/index.md))
- **AlertProperties** — behaviours such as highlight, jump, and display notification (see [Alert Behaviours](https://www.adaptabletools.com/docs/handbook-alerting-behaviours/index.md))

### Alert Type

There are 7 different types of Alerts in AdapTable

- This property is technically optional and will be inferred by AdapTable from object if not provided
- However we recommend always setting it to avoid any confusion

| Alert type                                                                             | Summary                                                                                                                                             |
| -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Data Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-data-change/index.md)         | Cell change makes a boolean **Rule** true; uses [Column Scope](https://www.adaptabletools.com/docs/dev-guide-columns-scope/index.md) and standard boolean expressions |
| [Relative Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-relative-change/index.md) | `ANY_CHANGE`, `PERCENT_CHANGE`, and `ABSOLUTE_CHANGE` on the changing cell                                                                          |
| [Row Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-row-change/index.md)           | Row added or removed (`RowChangeTrigger`); use AdapTable-aware row APIs (see that page)                                                             |
| [Aggregation Alerts](https://www.adaptabletools.com/docs/handbook-alerting-aggregation/index.md)         | [Aggregation Expressions](https://www.adaptabletools.com/docs/adaptable-ql-expression-aggregation/index.md) across multiple rows (e.g. limits on summed PnL)          |
| [Observable Alerts](https://www.adaptabletools.com/docs/handbook-alerting-observables/index.md)          | [Observable Expressions](https://www.adaptabletools.com/docs/adaptable-ql-expression-observable/index.md) — ticks, history, or no-change in a time window             |
| [Scheduled Alerts](https://www.adaptabletools.com/docs/handbook-alerting-schedule/index.md)              | Fires on a **Schedule** (one-off or recurring); no `Rule`                                                                                           |
| [Validation Alerts](https://www.adaptabletools.com/docs/handbook-alerting-validation/index.md)           | Rolls back edits that break the **Rule** before the cell commit completes                                                                           |

Having 7 different Alert types can sometimes be overwhelming.

So consult this table to work out which Alert Type is appropriate for your use case:

| If you need to fire an Alert when…                                  | Use                                                                                    |
| ------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| A **cell value** changes and a rule becomes true                    | [Data Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-data-change/index.md)         |
| A cell changed by a **particular amount** (% or absolute)           | [Relative Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-relative-change/index.md) |
| A **row is added or removed**                                       | [Row Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-row-change/index.md)           |
| A **summary across rows** crosses a limit                           | [Aggregation Alerts](https://www.adaptabletools.com/docs/handbook-alerting-aggregation/index.md)         |
| A a **live / history** rule becomes true (ticks, no-change windows) | [Observable Alerts](https://www.adaptabletools.com/docs/handbook-alerting-observables/index.md)          |
| A **calendar schedule** is triggered                                | [Scheduled Alerts](https://www.adaptabletools.com/docs/handbook-alerting-schedule/index.md)              |
| An **edit breaks a rule** and needs to be rejected                  | [Validation Alerts](https://www.adaptabletools.com/docs/handbook-alerting-validation/index.md)           |

### Alert Rule

The most common Alert Types all have a rule which is responsible for triggering the Alert.

These include Data Change, Relative Change, Validation, Aggregation, and Observable Alerts.

These Alert types also contain `Scope` which limits the rows or columns in the Grid the Rule applies to

The rule is evaluated with [AdapTableQL](https://www.adaptabletools.com/docs/adaptable-ql-expression/index.md) when data changes (or continuously for Observable).

- Row Change Alerts have an optional `Rule` that sets whether the added / removed row should trigger an Alert
- Scheduled Alerts have no Rule - the message comes from the Alert Definition

### Message Type

Each alert has a **MessageType** (`Info`, `Success`, `Warning`, `Error`).

This is used in the Alert toolbar, tool panel, status bar, and [toast notifications](https://www.adaptabletools.com/docs/ui-tutorial-using-toast-notifications/index.md).

| Message Type | Default CSS variable     | Default Colour                                   |
| ------------ | ------------------------ | ------------------------------------------------ |
| Info         | `--ab-color-info`        |   |
| Success      | `--ab-color-success`     |   |
| Warning      | `--ab-color-warn`        |   |
| Error        | `--ab-color-destructive` |  |

- Learn how to customise colours via [Customising an AdapTable Theme](https://www.adaptabletools.com/docs/handbook-theming-custom/index.md)
- Message wording is covered in [Alert Message](https://www.adaptabletools.com/docs/handbook-alerting-message/index.md)

## When an Alert Fires

Every fired Alert is recorded in numerous places in the AdapTable UI including:

- [Alert Toolbar](https://www.adaptabletools.com/docs/ui-dashboard/index.md#tabs-and-toolbars)
- [Alert Tool Panel](https://www.adaptabletools.com/docs/ui-tool-panel/index.md)
- [Alert Status Bar](https://www.adaptabletools.com/docs/ui-status-bar/index.md)

In addtional, AdapTable raises the [Alert Fired event](https://www.adaptabletools.com/docs/handbook-alerting-alert-fired-event/index.md).

There are many optional [Alert Behaviours](https://www.adaptabletools.com/docs/handbook-alerting-behaviours/index.md) (Alert Properties) that can occur when an Alert is triggered:

- highlight cell
- jump to cell
- jump to row
- log to console
- display in a custom container
- perform rollback (post-validation)
- display an [Alert Toast Notification](https://www.adaptabletools.com/docs/handbook-alerting-notifications/index.md) (plain message, command buttons, or a developer-defined form)

- [Alert Behaviours](https://www.adaptabletools.com/docs/handbook-alerting-behaviours/index.md) run immediately that the Alert fires
- Alert command buttons (and form buttons) run when the user clicks a button in the [Alert Notification](https://www.adaptabletools.com/docs/handbook-alerting-notifications/index.md)

## Alert options

There are many properties available in `alertOptions` in [Adaptable Options](https://www.adaptabletools.com/docs/technical-reference-adaptable-options/index.md) to configure Alerts including:

| Purpose                                            | Option                                                                          |
| -------------------------------------------------- | ------------------------------------------------------------------------------- |
| Highlight timing (ms)                              | `cellHighlightDuration` / `rowHighlightDuration` / `statusbarHighlightDuration` |
| Evaluate rules on `rawValue` vs `formattedValue`   | `dataChangeDetectionPolicy`                                                     |
| Cap stored fired alerts                            | `maxAlertsInStore`                                                              |
| One toast when a batch edit triggers many cells    | `consolidateBatchAlerts`                                                        |
| Dynamic message functions                          | `alertMessageHeader` / `alertMessageText`                                       |
| Full notification forms and custom button handlers | `alertForms` / `commandHandlers`                                                |

- See [Configuring Alerts](https://www.adaptabletools.com/docs/handbook-alerting-configuring/index.md) for highlight durations, batch consolidation, and detection policy
- Message functions are on [Alert Message](https://www.adaptabletools.com/docs/handbook-alerting-message/index.md)
- Forms and buttons on [Alert Notification](https://www.adaptabletools.com/docs/handbook-alerting-notifications/index.md)

## Server Side Row Model

Alert behaviour varies when using the [Server-Side Row Model](https://www.adaptabletools.com/docs/dev-guide-row-models-server-overview/index.md) based on the Alert Type.

`Data Change`, `Relative Change`, and `Validation` Alerts all evaluate normally on the client as cells change.

However `Aggregation` and grid-wide `Observable` rules may need rows that are not loaded and wont trigger an Alert.

You can [evaluate Alerts on the server](https://www.adaptabletools.com/docs/adaptable-server-evaluation/index.md) and return results to AdapTable when client-side evaluation is not sufficient

## Managing Alerts at run time

The Alert section of the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md) lists definitions with create, edit, delete, and suspend.

When an alert is **suspended**, it does not fire (but the object remains in State).

Observable subscriptions are removed until the Alert is unsuspended.

Set `DisplayNotification` to *false* to display triggered Alerts in the toolbar but without showing the Toast Notification

## UI Entitlements

- **`Full`** — normal create/edit/suspend UI.
- **`Hidden`** / **`ReadOnly`** — Settings Panel and module UI hidden or read-only; fired alerts still run for `ReadOnly` unless suspended.

## FAQ

**Can we show alerts in the system tray?**
Not directly — AdapTable is not able to access the OS tray.
Subscribe to the [Alert Fired event](https://www.adaptabletools.com/docs/handbook-alerting-alert-fired-event/index.md) and show UI wherever you need.

**Can we turn off pop-up notifications?**
Yes — set `DisplayNotification` to _false_ on the definition, or suspend the alert in the Settings Panel.
The `suspend` command button is also available on notifications (see [Alert Notification](https://www.adaptabletools.com/docs/handbook-alerting-notifications/index.md)).

**Can toast settings differ per Alert?**
No — per-alert properties control _whether_ a notification shows.
Duration and styling come from [Notification Options](https://www.adaptabletools.com/docs/technical-reference-notifications/index.md) for all toasts.
