When an event is executed with an Orchestrate workflow, the workflow is scheduled to run in the background. Orchestrate workflows can use SQL task types to update the results or status on the page. Control views on the page are used to ensure that buttons are disabled while the workflow is processing.
This knowledge base article walks through specific settings and a SQL example to manage the Orchestrate workflow status.
To manage the Orchestrate workflow status from Construct:
-
SQL Server: Create a data control view (Dcv) to disable the button that triggers the workflow in order to prevent starting the workflow twice with the same parameters. Write the Dcv so that it checks the WfStatus field:
- 1 = New
- 4 = Procedures Completed
- 11 = Processing
Here’s an example of the Dcv:
-
SQL Server: Call the business rule procedure before starting the workflow to change the WfStatus field to 11 (Processing). The workflow must contain a final SQL task to update the WfStatus field to 4 (Procedures Completed. Include dependencies in the tasks to ensure the task that updates WfStatus to 4 (Procedures Completed) is the last task to be executed. To avoid the WfStatus to be stuck in 11 (Processing) if the workflow fails, add another rule to change the WfStatus to 1 (New):
- Simple workflows: Enable “Continue On Failure” for any task in Orchestrate that may have an error
- Complex workflows: Add another rule to change the WfStatus to 1 (New) in Construct. This rule may be executed in the OnValidate event or in a “Reset” event.
- Orchestrate: Create a SQL task to update the WfStatus to 4 (Procedures Completed) once all tasks are completed. The task that updates the status must be executed after the other tasks via dependencies. Here’s an example of a Orchestrate workflow with variable tasks:
- Construct: On the Construct page that uses this Orchestrate workflow, set the RefreshRate property to a value greater than 0 so that when the workflow ends, the WfStatus changes and the button is enabled again. Otherwise, users must manually refresh the browser to check that the workflow is finished.