This post is part of a two step tutorial that walks through the process of creating a custom workflow to copy abstract or summary text of a list item into a separate list. This could be used when the list item needs to be returned in security-trimmed search results where a user may not be authenticated or may not have permission to the original content list item. After creating the workflow, it will be deployed to MOSS using a feature.
Pre-Requisite Installs
1. Install .NET 3.0 (this comes with WSS/MOSS)
2. Install the Microsoft Windows Software Development Kit for Vista and .NET 3.0 Runtime Components
http://www.microsoft.com/downloads/details.aspx?FamilyID=C2B1E300-F358-4523-B479-F53D234CDCCF&displaylang=en
3. Install Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF)
http://www.microsoft.com/downloads/details.aspx?FamilyID=F54F5537-CC86-4BF5-AE44-F5A1E805680D&displaylang=en
4. Install Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation)
https://www.microsoft.com/downloads/details.aspx?familyid=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=en
5. Set up the content lists:
a. Create two Document Libraries (or Custom Lists).
b. The "source" list name is not important, but the "destination" list should be named "DestinationContent".
c. Add a new single line of text column to each called "Abstract".
Let's get started with the solution….
1. First, let's open Visual Studio and create a new project
a. Under the Visual C# Project Type, select SharePoint and choose a SharePoint Server Sequential Workflow
b. Name the project: "CopyAbstractContent"
c. Click Ok

Notice that in Solution Explorer, we can see the template has created a Workflow1.cs file along with a DeploymentFiles folder.
For simplicity and consistency, I typically remove this folder and create my deployment files separately. You have to modify the files provided anyway and creating them manually allows me a consistent structure across all of my solutions. Also, I delete the .bat file and remove the Post-Build Event to call the .bat file from the project properties.
2. Delete the DeploymentFiles folder and create a folder called CopyAbstractContent
3. Inside the new folder, create two XML files: Feature.xml and CopyAbstractContent.xml. We'll come back to these files later
4. Double-click on the Workflow1.cs file.
We should now see the designer view of our workflow. Notice the onWorkflowActivated1 event that has been created automatically. This activity will fire when the workflow is activated.

We could enter all of our code in the onWorkflowActivated1 event, but as a best practice we should create our code elsewhere and leave this event to activation-type activities.
5. From the Toolbox, select the Code activity and drag it under the onWorkflowActivated1 event.
The screen should now look like this.

Notice the red exclamation icon next to our Code activity. This is because we have yet to define the code which will fire when the event executes.
6. Double-click on the Code activity in the designer window. Visual Studio will create a method for you to write code and automatically link it to the activity.
There are two important things to note here. Two private fields have been created above our code activity event method. These are the workflowId and workflowProperties. The workflowId is a unique guid that is assigned to a given instance of a workflow. The workflowProperties object is a collection of properties that relate to the workflow.
7. Add the following code to the activity event:
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
string title = workflowProperties.Item.Title;
string tempAbstract = workflowProperties.Item.Properties["Abstract"].ToString();
SPQuery qry = new SPQuery();
qry.Query = string.Format("<Where><Eq><FieldRef Name=\"Title\" /><Value Type=\"Text\">{0}</Value></Eq></Where>", title);
SPList lst = workflowProperties.Web.Lists["DestinationContent"];
SPListItemCollection itms = lst.GetItems(qry);
if (itms.Count == 1)
{
//update
SPListItem itm = itms[0];
itm["Abstract"] = tempAbstract;
itm.Update();
lst.Update();
}
else
{
//insert
SPListItem itm = lst.Items.Add();
itm["Title"] = title;
itm["Abstract"] = tempAbstract;
itm.Update();
lst.Update();
}
}
8. Close the Workflow1.cs file
9. Strongly name the output assembly (Project properties, Signing tab)
10. Compile the project to generate the CopyAbstractContent.dll file
11. Back to the two XML files we created earlier. Open the Feature.XML file.
12. Add the default feature snippet code
a. Right click on the page
b. From the context menu, double-click on Insert Snippet
c. From the sub context menu, double-click on SharePoint Server Workflow
d. From the sub context menu, double-click on Feature.xml Code
13. Modify the following properties:
a. Id (unique identifier for the feature we will use to deploy the workflow) VS2005 > Toos > Create GUID (Registry Format)
Remove "{" and "}"
b. Title (name of the workflow)
c. Description (description of the workflow)
d. Scope (location of where the feature will be deployed - e.g. [Farm], [Web], [Site] )
14. Modify the first node under ElementManifests
a. Change the Location to the name of your second XML file: CopyAbstractContent.xml
b. Remove the second node: <ElementFile Location="MyForm.xsn"/>

15. Open the CopyAbstractContent.xml file
16. Repeat the same steps we performed earlier to add a snippet, but this time select the Workflow.xml Code option
17. Modify the following properties:
a. Name (name of the workflow)
b. Description (description of the workflow)
c. Id (unique identifier for the workflow template -- each instance of a workflow will have its own Id as well)
d. CodeBesideClass (name of the namespace.class that contains the workflow)
e. CodeBesideAssembly (signature of the strongly-named assembly that contains the class above) -- use a tool like Reflector to retrieve the signature
18. Remove the following properties
a. TaskListContentTypeId (allows to specifies a custom content type used for tracking workflow tasks)
b. AssociationUrl (allows to override the association page for the workflow…we will use the default)
c. InstantiationUrl (allows to override the instantiation page for the workflow…we will use the default)
d. ModificationUrl (allows to override the modification page for the workflow…we will use the default)
e. StatusUrl (allows to override the status page for the workflow…we will use the default)
19. Delete the entire <MetaData>……</MetaData> node (and all nodes below)

That's it for the project setup!
See blog on Deploying a Custom Workflow Feature - coming very soon