I faced a problem while creating parallel tasks in state machine workflow. My requirement is same as OUT of Box SharePoint approval workflow which allows multiple users to approve the document and when everyone approves the document, document moves to next state which is approved.
All the articles pointed me that this is possible in sequential workflow.
Here is the thread which explains the problem, I am not going to invest much time to explain the problem
I downloaded the code sample available at Microsoft site which is basic state machine workflow. Following is the link.
Modifications to the code are as follows:
- Add a new state at level 2.
- In the state initialization, create two tasks with different Correlation token, task ids and task properties.
- Now add two event driven activity.
- Keep flags for each parallel task
- Added OnTaskChanged event driven activity, On Invoked event updated the associated flag to true.
- Put an IF block and check if all the flags are true, then set state workflow to next state.
I found this easy to implement, though manual code is involved which should be done via a parallel activity. Code can be downloaded from