21 ביולי 2008

Although it seems a fairly simple and commonly used task to get the context item (the item that the workflow is currently working on), it took me and Dor Rotman some digging to find the correct way to do it.

The first step is to add 3 properties to your activity, these properties have fixed names, I guess that in runtime the activity is loaded using reflection and the context variables are placed into these properties. To simply add a property in a workflow activity, you can use the code snippet wdp in visual studio 2005 (if you don’t have this snippet download the latest version of WF extensions for VS here)

The name of the properties need to be added are:

__Context

__ListId

__ListItem

After adding these properties your code should look like this: (note: change YourActivityClass to the name of your assembly)

And add the following to the parameters section of the actions file that you will create for you activity (located in: C:\program files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\[LOCALE]\Workflow )