Visual Studio 2010 Workflow + Infopath 2010 forms - troubleshooting
Microsoft markets that Sharepoint Designer workflows are directly exportable to Visual Studio workflows. And in many ways, this is absolutely true. It’s trivial to create a .wsp from an SPD workflow and import it to VS. However, if you then inspect the workflow that has been created for you, a little concern would not be underestimated. If your SPD workflow was what you wanted, then you could be reasonably confident that its VS version would do the same job. But presumably your reason for importing to VS is because you need more control over the workflow in the longer term, in which case, you’re likely to be left underwhelmed by what the import process creates for you. Imagine creating a webpage in Microsoft Word and you’ll get the drift.
So when faced with a similar proposition, recreating the workflow in Visual Studio from scratch immediately became apparent as the best solution. After all, the intent and purpose of the workflow was clear; recreating it in VS ought to have been a doddle. However, to complicate matters, the SPD workflow used Infopath edit forms. This turned out to be easy in SPD, but non-trivial in Visual Studio. Getting an Infopath form to register with a VS workflow project requires various items, that VS may not do automatically for you.
Things to check:
Chances are you’ll be using this guide and this guide to create your solution, which cover the majority of what you need to do. At time of writing, the images were broken in the second article, but the content of the article is complete. However, it doesn’t include all that is required. It either assumes various defaults or misses out some key steps. On the basis of that as the default, you may also need to check the following things.
- Set the content type of the list:
- In the Elements.xml file of your feature, check the existence of
- Further, in the
element of your feature, ensure the existence of
ReceiverAssembly=”Microsoft.Office.Workflow.Feature, Version 220.127.116.11, Culture=neutral, PublicKeyToken=71e9bce111e9429c” ReceiverClass=”Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver”
This will ensure that the Infopath form is registered in the site and shows up in ManageFormFeatures.aspx.
The advice in this walkthrough suggests that the ID used in the URN field is of the pre-published file. This is only correct if you publish to the same location as you to save to. So assuming you actually publish your form to a different location as your save location, then you actually need the ID of the published version of the form. This is the value you place between your <Form*_URN> fields.
Ensure you specify a TaskType value in your CreateTask action in your VS workflow. So for task 1 you may assign a TaskType of 0. For task 2, you may assign a TaskType of 1, and so on. This property replaces the * in your <Form*_URN>
Crystal? Please leave any other helpful hints and tips in the comments.