I recently took a look at using Windows Workflow Foundation to create a simple Human Workflow to manage a procurement process on SharePoint Portal Server. So I set about integrating SharePoint Portal Server (SPS), InfoPath and Windows Workflow Foundation to achieve this goal was it easy … well yes.
Here are the blog entries I can remember which really helped me out.
Windows Workflow + SharePoint 2003 + BizTalk Scenario Built Out (Unfortunately SharePoint Portal Server is not .net 2.0 compatible whereas SharePoint Services are)
Adventures with Windows Workflow – Hosting a Workflow with Tracing and Persistence
Windows Workflow Foundation ASP.Net State Machine
Basic user experience:
The InfoPath form was vaguely similar to the Purchase Request form which comes with InfoPath as a template.
- Go to a SharePoint form library and enter a procurement request using an InfoPath form and submit it
- An approver would then receive an email with a link to the InfoPath form asking them to click the link and then approve or reject the procurement they open the form, approve, reject and then submit it
- Reject send email with form link back to requester
- Approve send email to a higher approver or a PO issuer with form links they open the form, enter the PO number and then submit it
Note:
Only an approver can approve, only a PO issuer can issue PO numbers
I didn’t need to write a single line of code to create the InfoPath form it was super easy.
How it’s done
SharePoint Portal Server Event Sinks
As SPS 2003 is not .net 2.0 compatible I hosted my Win WF State Machine in an ASP.net 2.0 Web Service (I am going to go into greater detail of how to do this below).
I registered an ASP.net 1.0 event handler class (see following code) in the advanced settings of my Procurement Form Library on SPS. Each time an InfoPath from is saved or submitted this event handler is called. This just calls the ASP.net 2.0 Web Service passing the SPS site URL and the InfoPath file url so the State Machine can access, read and update properties on the InfoPath form.
Note you could just as easily not use the SPS event sink and call the web service from an InfoPath form, using the event sink just gave me an easy way of passing the SPS site URL and the InfoPath file url (from the SPListEvent arguement) to my Win WF hosting Web Service so I could gain control of the InfoPath form inside the state machine and modify it’s xml etc.
using System;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
<SPAN