Skip to main content













Case state machine

A case state machine defines what transitions between case statuses are allowed. For example, you can use the case state machine to allow a case status change from "Open" to "Submitted", but not from "Submitted" to "Open".

A case state machine is important when status updates aren't done programmatically, and the end-user of the app can choose between the different possible status.

To use a case state machine with the Case Management framework, you start by setting up the case state machine, and then you add all the allowed case status transition. If a status transition isn't define in the case state machine, it's considered invalid and an exception is thrown when an end-user tries to do that status transition.

Create the case state machine

Before you start make sure you set up your app to work with the Case Management framework.

To define a case state machine, follow these steps:

  1. In the <app-name>_Configuration module, open Manage Dependencies, and add the CaseStateMachine_CreateOrUpdate action from the CaseConfigurations_API producer.

  2. In the Data tab, create a CaseStateMachineConfiguration static entity with the following attributes:

    • Id, text data type with a length of 50.

    • FromCaseStatusId, CaseStatusConfiguration Identifier data type.

    • ToCaseStatusId, CaseStatusConfiguration Identifier data type.

    • Is_Active, boolean data type.

  3. In the Logic tab, open the Bootstrap_CaseConfigurations server action.

  4. In the action flow, add an aggregate that fetches all records in CaseStateMachineConfiguration by dragging the CaseStateMachineConfiguration static entity before the End.

  5. After the aggregate created in the previous step, add a For Each.

  6. Set the Record List of the For Each as GetCaseStateMachineConfigurations.List (the output list of the aggregate).

  7. Add CaseStateMachine_CreateOrUpdate action next to the For Each.

  8. Connect the For Each to the CaseStateMachine_CreateOrUpdate, and then connect the CaseStateMachine_CreateOrUpdate to the For Each.

  9. Set the CaseStateMachineRec of the CaseStateMachine_CreateOrUpdate as GetCaseStateMachineConfigurations.List.Current.CaseStateMachineConfiguration.

  10. Set the inputs of the action with the data from the aggregate:

    • Set Id as TextToIdentifier(Id).
    • Set CaseStatusId as TextToIdentifier(FromCaseStatusId).
    • Set NextCaseStatusId as TextToIdentifier(ToCaseStatusId).
    • Set IsActive as Is_Active.
  11. Publish the module by selecting 1-Click Publish

Add allowed status transitions

After creating the case state machine, add the allowed status transitions to the state machine by following these steps:

  1. In the <app-name>_Configuration module, add a record to the CaseStatusConfiguration static entity.

  2. Generate a GUID and paste that GUID into the value field of the CaseStatusId attribute of the <state> record.

    A Globally Unique IDentifier, or GUID, is used as a unique identifier to ensure integrity across environments..
    You can use an online GUID generator, to create a GUID for each record.

    Check the RFC 4122 for more information on GUIDs.

  3. Set the FromCaseStatusId as the CaseStatusId of the starting status.

  4. Set the NextCaseStatusId as the CaseStatusId of the ending status.

  5. Set IsActive as True.

  6. Repeat the previous steps for every allowed case status transition.

  7. Publish the module by selecting 1-Click Publish.

  • Was this article helpful?