Thursday, May 5, 2011

Deploying InfoPath 2010 forms for custom workflow with SharePoint 2010 and Visual Studio 2010

I've spent a little time recently structuring a solution in Visual Studio and TFS for an upcoming project that relies heavily on workflow. There are a couple of nuances that I thought I'd document given that the information out there at present seems fragmented at best.

The aim of this blog post is to provide guidance on how to structure a Visual Studio 2010 SharePoint workflow project that includes the deployment of InfoPath forms. This article will not repeat advice which is already in abundance that relates to core workflow development concepts. I assume you're familiar with writing custom workflow in Visual Studio 2008 and MOSS 2007.

Above we see the default solution structure for a state machine workflow.

Add a new Module named "InfopathForms"

You can remove the "Sample.txt" placeholder file. When you do this, notice that Elements.xml for the module will update automatically.


Add your InfoPath form to your InfopathForms module


Double check to ensure that the "Deployment Type" property of your InfoPath form is set to Element File and that the path is "InfopathForms\".

Your elements .xml file should now look like the following

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<Module Name="InfopathForms">

<File Path="InfopathForms\InitiationForm.xsn" Url="InfopathForms/InitiationForm.xsn" />

</Module>

</Elements>


By default, your feature.xml will look like the following:

<?xml version="1.0" encoding="utf-8" ?>

<Feature xmlns="http://schemas.microsoft.com/sharepoint/">

<Properties>

<Property Key="GloballyAvailable" Value="true" />

</Properties>

</Feature>


Now we need to modify our feature.xml to register the location of the forms we want to use and set the correct feature receiver. If you were used to using VSeWSS when developing workflows for MOSS 2007, these steps will have been undertaken for you automatically, you may have had to do little more than modify the path for the RegisterForms property below.

<?xml version="1.0" encoding="utf-8" ?>

<Feature xmlns="http://schemas.microsoft.com/sharepoint/" ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

ReceiverClass="Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver">

<Properties>

<Property Key="GloballyAvailable"Value="true" />

<Property Key="RegisterForms" Value="InfopathForms\*.xsn"/>

</Properties>

</Feature>



There are two additions here. The first is:

<Property Key="RegisterForms" Value="InfopathForms\*.xsn"/>

This tells our feature the location of the forms we want to deploy. In this case it is all of the .xsn files within the InfopathForms module.

The second modification is the feature receiver assembly and class:

ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"


ReceiverClass="Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver"

This is necessary in order for the forms to be present within the "Manage Form Templates" screen within Central Administration and is a necessary precursor to making your forms "Workflow Enabled".

At this point there is a ton of other work you need to do around building your workflow, registering your form URNs within the workflow elements file and any deserialization activities you need to do in order to take data from your initiation or association form into your workflow. None of this information is repeated here and I would point you towards MSDN and the numerous blog articles out there on these subjects.

Once you've deployed your solution, your form should now be registered in the correct location. Below we can see our IniitationForm at the top of the list within Central Administration.


Using Modules in this way to manage form templates means we simply need to drag and drop new xsn files into our Module and they will be automatically deployed with our solution. We still of course need to modify the workflow elements file to register the URNs etc but it's one less thing to think about and certainly makes deployment easier.

I hope you've found this article useful and that it saves you some time when transitioning from workflow development using VSeWSS in MOSS 2007 to Visual Studio 2010 with SharePoint 2010. Thanks for reading.

Wednesday, May 4, 2011

Migrating from Lotus Notes 8.5 to Microsoft SharePoint 2010: Real-world tales from the trenches

I've just published a new blog post on Nothing But SharePoint which outlines a real-world migration from Lotus Notes 8.5 to SharePoint 2010. I actually went live with this project on the day of the SharePoint 2010 global launch.

Read more here...