State Machines
State Machines (Business > State Machines) provide a visual workflow to show the progress of a task, with transition conditions and handlers that, when applicable, run code to result in specific actions, like sending an automated email or requesting specific information.
A State Machine needs a Codebook to represent the states of an Entity. The Entity must be referenced by the Codebook.
Each State Machine includes:
- Name - The name of the State Machine, which is not visible to users.
- Entity - The Entity that will be controlled by the State Machine.
- Codebook Representing States - The Codebook that will define the entity states.
- Current State Label Expression - Text attribute that represents the name of the state. It is shown on the Entity detail page. This is item.Name by default.
- Transition Label Expression - Text attribute that represents states to which the entity can transition. It is shown on the Entity Detail Page. This is item.Name by default.
The Entity needs to be connected to the State Machine:
- Go to Data > Entities and click on an Entity.
- Go to the
Settings
tab. - In the User Interface section, locate
State Machine
. - Select the State Machine.
- Select the
State Codebook Reference
.
The State Machine can be shown on the Entity Detail Page:
- Go to UI > Entity Pages.
- Select the Entity Detail Page.
- Go to the
Settings
tab. - In the User Interface section, locate
Show State Change Toolbar
. - Select True.
Transitions
Each transitions between states needs to be defined. On the State Machine page, in the State Machine tab:
Click Add New Transition
.
- Origin State (Required) - Choose the origin state from the entries of the Codebook.
- Destination State (Required) - Choose the destination state from the entries of the Codebook.
- Transition Handler - Establishes an expression that is executed when the transition is completed.
- Is Applicable - Establishes an expression that must be true for the transition to be allowed.
- Custom Transition Label Expression - Establishes an expression to represent the transition destination on the State Machine UI component.
Transition Conditions
Text becomes visible to the app users when defined conditions are met. Click Add New Transition Condition
under the applicable transition:
- Title of Condition - The text that will appear on the State Machine UI component for end users (e.g., "This Support Ticket is not assigned to you"; "A Description of Resolution is required").
- Description of Condition - Provides a tooltip next to the Title of Condition
- Severity - Definition for the behavior and visual output for the condition.
- Error - If the condition is not met, the Title is shown in red.
- Warning - The transition is allowed, but the Title is shown in orange.
- Info - The transition is allowed and the color of the Title is blue.
- Condition - The expression needs to be true for the transition to continue
- Is Applicable - The expression needs to be true for the condition to be evaluated (and shown on the User Interface)
State Extras
Lets you create universal transition handlers and transition conditions for states, regardless of the origin or destination state.
Click Add New State
:
- State Entry - Select a Codebook to represent the desired state.
- State Enter Handler - An expression that is executed after the entity transitions to this state.
- State Leave Handler - An expression that is executed before the entity transitions from this state.
After a "State Extra" is created you can create universal transition conditions for entering and leaving.