I faced a problem while creating parallel tasks in state machine workflow. My requirement is the same as OUT of Box SharePoint approval workflow which allows multiple users to approve the document and when everyone approves the document, the document moves to the next state which is approved.
All the articles pointed to 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 http://groups.google.com/group/microsoft.public.sharepoint.portalserver.development/browse_thread/thread/e0beac08110f6135.
I downloaded the code sample available at the Microsoft site which is a basic state machine workflow. Here is the link.
Modifications to the code are as follows:
- Added a new state at level 2.
- In the state initialization, created two tasks with different Correlation token, task ids and task properties.
- Now added two event driven activity.
- Kept 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. The code can be downloaded from here.