Thursday, October 16, 2008

Creating tasks inside a while activity of workflow

In many of the workflow based projects, one of the important workflow functionality used is "tasks creation". Many times these tasks will be created repeatedly for every process completed by the workflow.
In these kind of scenarios we may require the task creation inside a loop, using "while activity" or the "replicator activity". But if you would like to use the "Create Task" activity inside the "while activtiy", make sure you are doing the following settings correctly otherwise workflow will create the task first time but it will give the error in the subsequent loops.
1. Keep all the task related activities (mostly, "create task", "onTaskChanged" and "complete task") inside a Sequential activity.

2. Use a separate correlation token for the activities inside the "Sequential activity"

3. For all the activities inside the "Sequential activity", Change the Owner activity property value to the sequential activity(this is important)

Following picture shows a simple workflow which contains the "create task" activity inside a while loop. Note that all the task related activities are kept inside the "Sequential activity".


This picture shows the properties of "create task activity". Owner activity name and correlation tokens should be changed as shown in the picture. This needs to be done for all the task related activities inside the "Sequential activity"

8 comments:

Anonymous said...

Hi, is it possible to create the tasks parallel, i want to create tasks for one or more person and they should work parallel on the tasks.

Paulo said...

Hi!

First of all, congratulations for your blog...

I did understand what you say but I got a problem on my workflow.

When I complete one task, the others tasks get completed too!
What should I do?

Abdul Malik said...

how should I do, if I have sequenceActivity (we call: sequenceActivity1) inside sequenceActivity(we call: sequenceActivity2),
what correlation token for activity inside sequenceActivity1? it's reference to sequenceActivity1 or sequenceActivity2?
I've try your method, but in the second while, the task doesn't create and status "In prograss" (never completed)

Josep Immanuel said...

omg you just saved my ass :)
Thanks

Anonymous said...

Hi How to associate infopathTaskedit form into workflow in Vs2010 and SharePoint 2010...
MAil Id:sureshkumarlaksmi@gmail.com

Anonymous said...

Hi can you provide code for the above workflow. so that it would be more helpful.thank you
in advance

Anonymous said...

Your blog looks great. can you please provide a code example for this post?.It would be more helpful

Anonymous said...

Everything is very open with a clear clarification of the issues.
It was really informative. Your website is extremely helpful.
Many thanks for sharing!

Look into my weblog Mulberry Outlet