You are here
Querying Workflow Status and Information
In some integration scenarios it can be useful to query the state of a running workflow. Since the workflow's Id is needed in order to query it's status, querying the state of a workflow is almost always used in conjunction with one of the two BPMInitiateWorkflow methods. At a high level, this equates to kicking off a workflow batch job in SpringCM, polling for it to complete, and then optionally pass data back from the workflow to the web services client. Implementing this would be as follows:
- A workflow is initiated with either the BPMInitiateWorkflow or BPMInitiateWorkflowWithDocuments method. The workflow's Uid is passed back in response which is subsequently used to query the workflow's state. Note that SpringCM workflows have both a Uid (GUID) and a friendlier all numeric unique identifier that is seen in the workflow Process Monitor. Either can be used to check the status of a workflow and will return identical information.
- The resulting workflow Id can be used to get the instance information from a workflow by calling the BPMWorkflowInstanceInformation method. An SCMInstance object is returned and includes the Id,Name, Status, data in the information column, and start and end dates of the workflow instance. Note that if this method is called directly after the workflow initiation is requested, it is possible that workflow execution may be queued for a short a period of time. While the workflow is queued, the BPMWorkflowInstanceInformation may return no information or an exception. It is for this reason a retry should be used when calling this method as shown in the examples below.
- The client code may continue to poll the BPMWorkflowInstanceInformation method until the workflow is "Completed". In the case where the workflow is designed to pass information back to the web services client, the workflow can be designed to update its "Information" with data that can then be read by the web services client.
- Even if data does not need to be passed back, these methods can still be used to make sure that an initiated workflow executes successfully.