---
title: "on state changed"
canonical: "https://support.appfire.com/space/CDMC/2193787277/on%20state%20changed"
format: markdown
---
> Macro (aura-html)

## Overview

Use the **on state changed** (`on-state-change`) event in a workflow trigger to detect when a document transitions from one workflow state to another. When this event occurs, the trigger can perform one or more actions.

You can add a condition to the trigger to limit it to specific transitions—for example, only when the document enters a **named state**, such as the workflow's **initial** or **final** state.

## Example `“on-state-change"` event

```
"triggers":
[
    {"event": "on-state-change",
    "conditions":
    [
        {"final":true}
    ],
    "actions":
    [
        {"action": "clean-messages"}
    ]}
]
```

The trigger action clears any existing messages on the content

- `"actions":[{ "action":"clean-messages"}],`

The messages are only cleared on the change of state to the final state in the workflow

- `"conditions": [{"final": true}],`