I want to write a workflow which creates and updates tasks when the workflow item is changed. For example: the workflow-item has a multivalue field with users who should approve the workflow-item:
- When the item is created, the workflow has to create a task for each approver
- When the workflow-item is changed the workflow has to change the description of every task.
Part 1 (creation of multiple tasks) is more or less easy: I used a replicator activity (an example for this can be found in http://www.shillier.com/archive/2010/08/04/Creating_Multiple_and_Parallel_Tasks%20_in_SharePoint_2010_Workflow.aspx)
Part 2 (updating all tasks which were created in Part 1) is difficult:
I tried to write a CodeActivity
, which iterates through all tasks and changes them via AlterTask-calls. This works perfect for the first time, but if I try to alter the same task a second time I get an exception, because the workflow has locked the task.
Another idea was to change the tasks with an UpdateTaskActivity
. But this is difficult, because I have an arbitrary number of tasks and cannot define the right CorrelationToken for the UpdateTaskActivity
.
Does anyone know a solution for this?