[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Collapse]eXpressApp Framework
 [Expand]Fundamentals
 [Expand]Getting Started
 [Collapse]Concepts
  [Expand]Application Solution Components
   Client-Side Mobile Application
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]UI Construction
  [Expand]Extend Functionality
  [Expand]Data Manipulation and Business Logic
  [Expand]Security System
  [Expand]Localization
  [Expand]System Module
  [Collapse]Extra Modules
   [Expand]Audit Trail Module Overview
    Business Class Library Customization Module
    Chart Module
    Clone Object Module
   [Expand]Conditional Appearance Module Overview
   [Expand]Dashboards Module
    File Attachments Module Overview
    HTML Property Editor Module
    Localization Module Overview
   [Expand]Notifications Module
    KPI Module
   [Expand]Maps Module
   [Expand]Pivot Chart Module
    Pivot Grid Module
   [Expand]Reports V2 Module
   [Expand]Reports Module (Obsolete)
   [Expand]Scheduler Module
    Script Recorder Module
   [Collapse]State Machine Module
     State Machine Module Overview
     User-Defined State Transitions Specified at Runtime
     Predefined State Transitions Created in Code
   [Expand]TreeList Editors Module
   [Expand]Validation Module
    View Variants Module
   [Expand]Workflow Module
  [Expand]Debugging, Testing and Error Handling
  [Expand]Filtering
  [Expand]Application Life Cycle
 [Expand]Design-Time Features
 [Expand]Deployment
 [Expand]Task-Based Help
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
This documentation page describes implementations made in our v17.2 release cycle. To learn about functionality shipping with v18.1, navigate to our updated help file experience at docs.devexpress.com. Learn More

User-Defined State Transitions Specified at Runtime

This topic describes how users can create and customize State Machines at runtime.

When the State Machine Module is added to an application, the State Machine navigation item is created automatically. This navigation item invokes a List View where you can create and customize persistent objects that define state machines.

State Machines are persisted using business objects (entities) that implement the DevExpress.ExpressApp.StateMachine.IStateMachine interface. If you are using XPO, the DevExpress.ExpressApp.StateMachine.Xpo.XpoStateMachine persistent class and its associated types are used automatically. If you use Entity Framework, you should manually add the following entities from the Business Class Library to your DBContext.

To create a new state machine, use the New Action.

When creating a state machine, specify its name, the target business class, and a property whose values represent the state of a business class instance. This can either be an enumeration property or a reference property. Property values are used as state markers. Different states must use different marker values. You can now create states and transitions.

Note

To make a required business class available in the Target Object Type combo box, please add an enumeration or reference property (which will be used as a state marker) to this class.

When creating a state, specify its caption and corresponding value of the marker property. You can optionally specify criteria that an object must satisfy in order to obtain the current state. If the object does not satisfy the target object criteria, and a user tries to execute a transition to the state, the user is warned and the transition is canceled.

Finally, specify transitions allowed for the current state and optionally, the appearance rules associated with the current state. The specified appearance rules will be in effect while an object is in its + current state.

To control the visual order of state transitions, specify their Index property. Actions corresponding to state transitions are ordered according to their indices. To specify that a state transition should save the current object and to close the Detail View after execution, check the Save and Close View check box.

As a result, the StateMachineController will add the ChangeStateAction Action to Views that display objects of the type specified using the Target Object Type property.

You can optionally check the Expand Actions In Detail View checkbox. In this instance, the target objects type's Detail Views will contain separate Simple Actions corresponding to available state transitions.

Note

Correct security permission configuration may be required when the State Machine module operates with data protected by the Security System. Read permissions should be granted to data required by State Machine, and write permissions should be granted to data that will be modified, as the State Machine cannot bypass the security restrictions.

Is this topic helpful?​​​​​​​