Accessing previous activity instances in a sequence activity

Posted by Dan Revell on Stack Overflow See other posts from Stack Overflow or by Dan Revell
Published on 2010-06-11T14:49:32Z Indexed on 2010/06/11 14:52 UTC
Read the original article Hit count: 346

Filed under:
|

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 as the CreateTask runs for all the replications before the CodeActivity gets to runs.

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.

© Stack Overflow or respective owner

Related posts about sharepoint

Related posts about Workflow