Hi, I want to show you a simple workflow Patern to implement to avoid to be stuck wille using a component workflow. This sould be use every time when we use a component worklfow.
Avoid being stuck wille calling Components Workflows
If you have used Nintex for Office 365, you may have used component workflows (simply put, these are "sub-workflow" calls), which are bits of workflows whose execution is triggered by other workflows in order to improve performance or allow reusability of specific actions.
However, when using a component workflow (CWF) in a workflow (WF), our workflow may end up getting stuck. If the calling workflow is waiting for the end of execution of the component workflow ("Wait for Component Workflow to complete before continue") and the component workflow is in error, then the calling workflow will remain in a blocked state (it will still be in progress, without any error message). Indeed, it is waiting for the end of execution of the component workflow instance, which will be in error, the instance of the component workflow will never be finished normally and will never give back the hand to the calling workflow. The only solution would be to manually force the calling workflow to terminate and restart it, which is not a viable solution.
The main principle
Use a parallel block to run in competition :
- The call to the component workflow
- A pause for a certain amount of time. After this time, the component workflow will consider that the component workflow has crashed and will continue its execution. Some variable values will be defined (default values for the variables to be returned by the workflow component so that the workflow does not crash, if these variables are required).
The design of the workflow is shown in the picture :
The implementation
Step | Action | Comment |
1 | Set Worklow variable ("init Continues") | Set a boolean type "Continue" variable to "False" |
2 | Parallel Block | Set the "completion conditon" to the "Continue" variable. As long as it is false, the parallel block will wait for the completion of both branches. It is one of the two branches that will tell the workflow to continue (either when the component has finished its execution or when the estimated execution time of the workflow component has passed). |
3.A | Left branch Run Component | Call your component workkflow |
4.A | Left branch Set variable ("Set Continue") | Set the value of the variable "Continue" to True |
3.B | Right branch: Pause ("Pause for 1h") | Pause for a while. After this time, it is considered that the component workflow is in error/not able to respond.In the example, this is a one hour pause (which usually allows time for a workflow to run). |
4.B | Right branch: Logging in history | Log in our workflow history to say that the workflow component is in error |
5.B | Right branch: Set variable ("Set default value"): | Set the value of the variable "Continue" to True. Set default values for the variables that is normaly filled by the component workflow. |
At the output of the parallel block, there are two cases:
- The execution of the component workflow has been run successfully, all the variables will have the values returned by it.
- The execution of the workflow component is in error, then all the variables will have the default values defined in step 5.B.
All that remains is to manage this last case in the logic of your workflow.