views:

72

answers:

0

This has a rather SharePoint spin to it but the problem is straight workflow.

I've got a parallel replication activity which contains a sequence activity. The sequence activity contains a CreateTask activity, a CodeActivity, a OnTaskChanged activity and finally a CompleteTask activity. The idea is to create a task for each username passed into the ReplicatorActivity.InitialChildData property.

Typically in workflow I bind a field to the CreateTask.TaskId and CreateTask.TaskProperties and inside the CreateTask.MethodInvoking I set these through the local bound fields. This works and my tasks all get created properly.

However in the CodeActivity that follows, I want to then access the TaskProperties. The problem I am encountering is that this field holds the values of the final task to be created. I believe this is because the CreateTask activities all run before the first CodeActivity in this "parallel" context. I think the local bound fields get set, and then for the subsequent CreateTask activities I set them again overwriting the previous value. Therefore the values it will hold are that of the last CreateTask to run. Or at least I think this is the reason.

From the CodeActivity, here are two ways I've tried to access the CreateTask activity instance from the same context or instance or whatever the terminology is for the replicated sequence.

CreateTask task = ((CreateTask)sender.Parent.GetActivityByName("createSoftwareRequestTask", true));
CreateTask createTask = (CreateTask)sender.Parent.Activities[0];

Unfortunately the CreateTask activities both refer back to the last task to be created and not the task from the context that the CodeActivity is executing within.

Two reasons why this might be that I can think of.

  1. I'm not accessing the correct instance with my code.
  2. I am accessing the correct instance, but as the properties I require were bound to and set through local fields then their previous data was overwritten.

I'm hitting a brick wall with my understanding of workflow with this and would very much appreciate some assistance here.