There is a lot of content on the web around custom Windows Workflow Foundation (WFF) workflows and how they integrate into SharePoint. However, I couldn't find a post or article that contained the basics steps to deploying a workflow that wasn't watered down with the useful, yet complicated intricacies and specifics that make it difficult to learn WFF for beginners. This post is my attempt to help those who tend to learn better by doing, rather than reading…
The workflow I'll be walking you through will bind to a SharePoint list, and when a new list item is added, the workflow will fire and create a new task in a Tasks list. This is a pretty basic example, but it serves to demonstrate the concept of creating and deploying workflows. This first part in the 2 part series walks you through creating the workflow in visual studio.
Part 1: Building Your Custom .NET Workflow
- Download and install Visual Studio Extensions for .NET 3.0 (WSS 3.0 Tools extensions may be needed as well, I can't remember).
These extensions are required to create workflow projects with Visual Studio.
- Create a new SharePoint Sequential workflow called "NewTaskWorkflow".

(Figure 1 – new project window showing SharePoint workflow template)
You can create a sequential workflow under the "Workflow" section, rather than the "SharePoint" section, however, you will not get the feature files we'll use to deploy this to our SharePoint site.
Notice the solution explorer has our feature files that will be used to install the workflow onto the SharePoint site. Also, the template gives us production deployment files that we can use to create a SharePoint Solution and deploy our workflow across the entire farm. For the sake of simplicity, I'm not going to demonstrate that concept now, and I will simply do a manual deployment of the feature files.

(Figure 2 – workflow project's default configuration)
Double click on Workflow1.cs and you'll be brought to the workflow designer interface. By default, only one workflow item is in the workflow, the onWorkflowActivated1 item. This is a good item to use if you need to set state upon initiation of the workflow.

(Figure 3 – Workflow's drag and drop designer interface)
- Open the toolbox and drag the "Create Task" workflow activity onto our NewTaskWorkflow designer.

(Figure 4 – project toolbox containing all available workflow activities)
- Notice the red exclamation point next to the new activity we just added. If you click on the activity and view the properties, you'll notice there's a property that we need to take action on:

(Figure 5 – the CorrelationToken property is not set)
Click in the box and set the token to something like "TaskToken". After you set the token to "TaskToken", you'll notice a plus sign appear to the left of the property. Click the plus sign and select the drop down and set the ownership to Workflow1. Thereafter, the red exclamation point will go away.

(Figure 6)
You can use these tokens to associate a set of activities with one another. A good way to think about it is a particular workflow may have several paths of events, wherein each path's activities should be "correlated" to one another so their outputs don't affect other paths and activities that are not related. Specifically, these tokens refer back to the SharePoint list items, in this case the specific task. Click here to read more on correlation tokens.
- Now that our activity is correlated, we need to alter it in some way so you know that our code can interact with the workflow. In addition to this, we need to do some tricks to get the createTask action to function. Let's start by setting the TaskID and TaskProperties properties of the createTask activity. Click on each property and select the ... icon and enter "myTaskID" and "myTaskProperties" respectively:

(Figure 7)
For the sake of demonstration, we'll just set the Title column of the task to a unique string and the task ID. Right click on the createTask1 activity and choose "Generate Handlers". This will wire-up a method that is invoked when the workflow reaches this activity. Here is where I'll set the title of the task and the ID.

(Figure 8 – handler that sets the title of the new task item the will be generated)
If you did these steps you have a working workflow that you can now deploy into SharePoint! It's pretty easy huh?
My next post will contain the steps necessary to deploy the workflow we just created. I'll also at that point publish my project source for your viewing pleasure. Stay tuned, I should have part two up in the next couple days.
Cheers!