expressappframework-113713-business-process-management-state-machine-state-machine-module-overview.md
Business objects often have an associated state specified by their property values (for example, a Task object has a status that can be NotStarted, InProgress, and so on.). While this state can easily be changed by modifying corresponding property values, managing state transitions in a uniform way is not that simple. This is why XAF ships with the State Machine module, which greatly simplifies state transition management.
The module creates a set of Actions that correspond to state transitions and display them in corresponding Views.
With the State Machine, you can:
Important
In certain scenarios, creating a custom Controller with the SingleChoiceAction Action or a set of SimpleAction Actions can be simpler and more straightforward than defining a coded State Machine. So, if you need to define a static state management process that should not be changed by users, consider this approach first instead of using the State Machine module.
See Also:
How to: Include an Action to a Detail View Layout
Note
In the DataView, ServerView, InstantFeedback, and InstantFeedbackView data access modes, State Machine requests selected objects from the database each time the selection is changed.
To add the State Machine module to an ASP.NET Core Blazor or WinForms existing application, install the DevExpress.ExpressApp.StateMachine NuGet package and register the State Machine module in a platform-agnostic module (MySolution.Module):
public sealed class MySolutionModule : ModuleBase {
//...
public MySolutionModule() {
InitializeComponent();
this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.StateMachine.StateMachineModule));
}
}
Note
You can add modules to your application when you use the Template Kit to create a new XAF solution. Select modules in the Additional Modules section.
To add an extra module in code, add it to the XafApplication.Modules or ModuleBase.RequiredModuleTypes list (adding a reference to the module assembly is insufficient).
In XAF applications, you can call the AddStateMachine<TBuilder>(IModuleBuilder<TBuilder>, Action<StateMachineOptions>) method in your ASP.NET Core Blazor/WinForms application builder.
See Also