There are loads of articles and blog posts about creating SharePoint 2007 custom workflows using Visual Studio but most of them only tell part of the story or have certain steps missing. Nick Swan has probably come closest with his post for Visual Studio 2005 but even with a post as comprehensive as this it is clear from the comments that it is something people still struggle with. Rather than rehash all of those posts I thought it would be more useful to provide an example Visual Studio 2008 solution that is already set up and ready to go.
This article does not aim to be a comprehensive guide to setting up a custom workflow. It is aimed at a .net developer audience who are already familiar with SharePoint and InfoPath development but who just need a bit of help bring all the bits of SharePoint custom workflow development together into a working solution.
This solution was created using STSDev v1.4 which gives a good starting point for a sequential workflow solution and automatically creates a .wsp file whenever the project is built. If you are not familiar with STSDev projects the .wsp can be found in the Deployment folder of the project.
In the project I have included the more common generic elements for a custom SharePoint workflow:
- An InfoPath initiation form that allows the user to provide information to the workflow task. In this case the workflow task title is set and a property is stored to be displayed later on the task form.
- An InfoPath task form that displays information from the initiation form and allows the user to approve or reject the the item.
- The sequential workflow itself - wiring this up is often a place where people miss something or make mistakes.
- A WorkflowTestInitForm.cs file that is used to make the information typed into the initialisaton form available in code. See comments in this file to generate your own.
- An ItemMetaData.xml file that is used by the InfoPath task form as a secondary data source so that the information supplied by the initiation form can be displayed.
The code has been commented to provide additional information and guidance on how to set up your own workflows. For the solution to work the only thing you have to change before building and deploying the .wsp is line 62 in SequentialWorkflow01.cs - the task assigned to property must be set to a user that is valid for your environment.
To open the solution just save this zip and extract in your development environment - AidanWorkflowTest.zip (91.97 kb)