Wow, it's been a while since I blogged on this...time flies. If you've been following along with my previous posts, you'll have seen some of the other Create Your First OBA posts. Here they are if you haven’t seen them:
1. Creating the VSTO document-level solution (i.e. the custom document);
2. Deploying the VSTO document-level solution;
3. Integrating the VSTO with SharePoint content type;
4. Associating SharePoint workflow with VSTO document-level solution;
5. Customizing SharePoint (BDC);
6. Customizing SharePoint (Excel Services).
This post describes how you can add workflow to your OBA.
First, let me say that I can’t believe the amount of people who are asking me about this. I’ve presented at a number of conferences over the last few months and I’ve been getting more questions around this particular subject. That said, a specific walkthrough on exactly how to do this is quite long so I’ll walk through at a high level what you need to do, and then I’ve added a few references for you and also attached a hands-on lab that you can use as well to walk through—complete with code samples.
You’ll also note that the code samples cover other areas of OBA development—mainly covering client-side development using VS 2008 (specifically VSTO 3.0). Some great code samples and walkthroughs, so enjoy.
Okay, back to workflow. To create a SharePoint (SP) workflow you first need to make sure you have an ‘object’ within SP against which you’ll build the workflow. A Word document might be an example or an InfoPath can be another example. You then need to figure out what type of workflow you’re going to build and what the workflow will do. The SP workflow derives from the Windows Workflow Foundation (WF) workflow types in the .NET Framework 3.0, so the two main types are Sequential and State Machine. Sequential being as it sounds: a workflow that follows a particular sequence. And State Machine being a workflow that moves along to the next ‘activity’ depending on the state of the workflow. An activity are the individual actions that make up a workflow. If you’d like more details on SP WF, you can check out these links here:
1. Book excerpt from Programming Office Business Applications: http://msdn.microsoft.com/en-us/library/cc534997.aspx.
2. You can also find some articles here in the VSTO 3.0 documentation: http://msdn.microsoft.com/en-us/library/bb386211.aspx.
So, once you’ve figured out what your workflow will do (and let’s assume for simplicity sake that you’re going to build a Sequential workflow), you then open Visual Studio 2008, click File, New, Project, select the Office node under the language node of your choice (i.e. either VB or C#) and then select SharePoint 2007 Sequential Workflow, give it a name and click OK. This will invoke a wizard that will enable you to give the workflow a name and map the workflow template (each workflow is built and deployed as a template) to your specific SP site. Once this is done, click Next and then you can select the library or list you want to associate your SP workflow with, the History list and then the Tasks. In mine, I had a document library for the custom Word document I built earlier in the blog series (called Annual Reviews) so I built a small approval workflow (that updated a status note that corresponds to that particular document library. At this point, VS creates a project shell with a number of items in it. You can drag and drop activities onto the designer, add code behind for the activities and then map the properties of the workflow to the activities to make sure everything works. You can then press F5 to test out your workflow and it will invoke SP and run your workflow.
Now, keep in mind I just encapsulated in one paragraph what will take you an hour to walk through in the attached hands-on lab—which is why I chose the really condensed version—and even longer when you’re planning out your own SP workflow. I did this to not only save some time in writing the blog, but also because the resources I’ll provide below will help you just as much if not better.
So, here’s what I would recommend as next steps for you to get really get stuck into learning SP workflow:
1. Take a look at the attached hands-on lab and walk through lab #4. It’s an awesome and simple example of how to quickly create a simple workflow. (The lab uses VS 2008 (VSTO 3.0), and you'll need to have Office 2007 installed and a MOSS 2007 server available to build your workflow against.)
2. Take a look at the following web cast. It’s a great intro to SP workflow and provides you with some deeper-level information: http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&EventID=1032378840&CountryCode=US.
3. Take a look at following new site for SP developers; it’s got some awesome content: http://mssharepointdeveloper.com.
Okay, hopefully that will get you started.