Home > C#, Code, Development, Grumbles, MOSS, Workflow > MOSS Workflow Activity Events

MOSS Workflow Activity Events

It bugs me when the very ‘supposed’ leaders on MS product ‘code consistency’ don’t follow their own rules. Case in point: MOSS Task Activity events.

For example, the OnTaskChanged event has the following signature: (object sender, ExternalDataEventArgs e)

However the sender is always null. In order to get at the task that raised the event one needs to get at ((SPTaskServiceEventArgs)e).taskId.

Here therefore, are some others I’ve found to help my fellow ‘flow’ers to hook up multiple events to the same handlers (although I’m hoping that SP1 might ‘correct’ the lack of sender consistency):

OnTaskCreated

(object) sender or ((Microsoft.SharePoint.WorkflowActions.CreateTask)sender).ListItemId

Notes:

1. To get the name of the task that raised the event use sender.ToString().Substring(0, sender.ToString().IndexOf(” “)).

2. You’ll need to populate ListItemId in the designer – due to the nature of when this event is raised, there is no real useful info available prior to the call.

OnTaskChanged

(ExternalDataEventArgs) e

Notes:

1. To get at the tasks underlying GUID use ((SPTaskServiceEventArgs)e).taskId.

2. (object) sender is always null

OnTaskCompleted

(object) sender

Notes:

1. The tasks GUID can be located with ((Microsoft.SharePoint.WorkflowActions.CompleteTask)sender).TaskId.

2. The tasks name can be isolated with sender.ToString().Substring(0, sender.ToString().IndexOf(” “))

IfElse

(object) sender

Notes:

The name of the IfElse activity that raised the event can be found using sender.ToString().Substring(0, sender.ToString().IndexOf(” “)).

About these ads
  1. No comments yet.
  1. No trackbacks yet.

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 71 other followers

%d bloggers like this: