IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Developing business processes > Building business state machines
Querying the status of a business state machine in the runtime environment
When an instance of a business 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:
Procedure
- To return the internal name of the currently active state, add an operation called getState to one of the business state machine's interface definitions and proceed as follows:
- Set the input of this operation as the correlation value of the associated process instance.
- Name the output state, and give it a data type of string
- Similarly, to return the display name of the currently active state, add an operation called getDisplayState.
- Set the input and output parameters to match those of getState.
Results
During processing, the runtime environment will automatically generate variables for both of these operations.
What to do next
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 business 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 BPEL process that calls this business state machine is set to automatically delete upon completion, then calling the getState operation when the business 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 business state machine.