Querying the status of a state machine in the runtime environment

When an instance of a state machine is active in a runtime environment it will always be in one of its available states, and queries can be made to determine what this state is.

To enable a user in the runtime system to determine the state that is currently active, proceed as follows:
  1. To return the internal name of the currently active state, add an operation called getState to one of the state machine's interface definitions and proceed as follows:
    1. Set this operation's input as the correlation value of the associated process instance.
    2. Name the output state, and give it a data type of string
  2. Similarly, to return the display name of the currently active state, add an operation called getDisplayState.
    1. Set the input and output parameters to match those of getState.
During execution, the runtime environment will automatically generate variables for both of these operations.
Your new operation will appear as shown in the screen capture below.A screen cap showing the new operation called getState.
Note: The data in this procedure may not always be current for either of the following reasons:
  • The getState and getDisplayState operations run in their own transactions. If the state machine instance you are trying to query is currently in a transaction, these operations will not have access to the current values of the state and display state. Simply put, the output of these operations is always state and display state that was last committed to the database.
  • If the business process that calls this state machine is set to automatically delete upon completion, then calling the getState operation when the state machine has already terminated will result in a correlation error because the correlation set no longer exists. You can get around this by changing the configuration setting in the Details Property page of the process that implements the state machine.

Feedback
(C) Copyright IBM Corporation 2005, 2007. All Rights Reserved.