Multiple Event Driven Activities in a Single Workflow State

I was working on developing a Custom State Machine Workflow in MOSS and had following scenario in a particular state of the workflow:

Create a Task –> Wait for Task to Be Created –> Send Email Alerts –> Wait for the User to Take Action on the Task.

To create a state activity with above scenario, I created a state activity that looked like:

Workflow Event Driven Activity in State Acitity
Figure 1

StateInitialization Activity contains CreateTask Activity

Workflow TaskCreate Activity
Figure 2

EventDriven activity contained following:

Workflow Event Driven Activity in State Acitity
Figure 3

Well the problem is “Only the first child activity of ‘EventDrivenActivity’ can implement the ‘System.Workflow.Activities.IEventActivity’ interface”

The solution is you can have State Activity within a state activity:

Workflow Event Driven Activity in State Acitity

Figure 4

First Child Activity’s StateInitialization contains CreateTaskActivity and EventDriven activity of the First Child contains OnTaskCreated Activity and SetState Activity to Set the state to Second Child (Child2)

Figure 5

Second Child’s EventDriven looks like:

Now you can have two Event Driven Activities in a single state!

Finally make sure the Correlation token’s Owner Acitity is the parentState Activity and not the Child State activity

Download the Sample Code here.

Advertisements

10 thoughts on “Multiple Event Driven Activities in a Single Workflow State

  1. Hi Ketul,

    great post – I’ve just started getting to grips with state machines. I find that most workflow books out there afford little time for them and many of their subtleties are not covered.

    Just one thing – the sample code download link is not correct – I think you need to prepend http:// to it so it doesn’t think it’s a relative link.

    (Still managed to download the sample though – thanks).

    Shane.

  2. Hi ketul,

    great post , iam facing the same problem but however instead of single ontaskchanged event i want two of them (parallel Activity in one state. lemme know if there is any solutions for this..

    Regards
    Aman

  3. This is exactly what I need to do the problem is none of your images is displaying and the link to the code doesn’t work

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s