Sunday, January 9, 2011

Moss 2007 Workflow with InfoPath “Specified Form Cannot be found" Issue RESOLUTION

Following are the steps to resolve “Specified Form Cannot be found" Issue:

 

Step 1 Feature Definition (Feature.xml)


<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="MyCustom Request Center Workflows"
Description=""
Id="cc670ffe-fb03-4eb2-8f74-0a70be5cf102"
ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" ReceiverClass="Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver"
Scope="Site">
  <Properties>
    <Property Key="GloballyAvailable" Value="true" />
    <Property Key="RegisterForms" Value="HardwareRequest\*.xsn" />
  </Properties>
  <ElementManifests>
    <ElementFile Location="HardwareRequest\ApproverTaskForm.xsn" />
    <ElementManifest Location="Elements.xml" />
    <ElementManifest Location="RequestPreProcessEvntRcvr\Elements.xml" />
  </ElementManifests>
</Feature>

Register the Form

 

The feature definition file for the workflow is very similar to any other SharePoint feature definition.  The big key here when using InfoPath for your workflow forms is to make sure that you declare the forms you wish to register for use with your workflow.  This is done by adding the following properties to the manifest of the feature:

<Property Key="GloballyAvailable" Value="true" />
<Property Key="RegisterForms" Value="HardwareRequest\*.xsn" />

Note above that the path used in the “Value” of the “RegisterForms” property is a relative path to the feature.  This means that your forms need to deployed in the same feature folder as the workflow.  When using the VS2010 Workflow Template a folder is created in the project with the name of your workflow.  you will want to copy your InfoPath form to this folder.  If you have multiple forms or like to keep things organized then you can create a subfolder at this location and place your form there,  just make note of the RELATIVE path. SharePoint OOB has a folder called “Forms” which stores the IP Forms for all the OOB workflows.
The other thing to point out here is that you MUST use the following feature reciever for your workflow to register correctly:

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

NOTE:The above assembly are OOB the box with SharePoint and your form will not display correctly if you do not use this feature receiver.  Without this I was getting “Specified form cannot be found!”  when I tried to perform a workflow action which used my form!

Step 2 Workflow Definition File

 

  <Workflow
Name="Hardware Request"
Description="This workflow will send the request through the hardware request process.  This workflow will be for hardware requests only!"
Id="f25f4deb-4be2-4b14-bbee-f4db163cd7bc"
CodeBesideClass="MyCustom.RC.WF.HardwareRequest.HardwareRequest"
CodeBesideAssembly="$assemblyname$"
Title="Hardware Request"
TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"
ModificationUrl="_layouts/ModWrkflIP.aspx">
    <Categories/>
    <MetaData>
      <AssociationCategories>List</AssociationCategories>
      <StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl>     
      <Task0_FormURN>urn:schemas-microsoft-com:office:infopath:ApproverTaskForm:-myXSD-2010-07-06T02-25-34</Task0_FormURN>     
    </MetaData>
  </Workflow>
</Elements>
Turns out this file is pretty straight forward and all the MSDN documentation get this one right.  Please refer to MSDN for more details on specifying the form for your Association forms, Initiation Forms, and/or Task forms.  The key change here is to make sure the TaskContentTypeId is set to the OOB SharePoint InfoPath Workflow Task Content Type:
TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"
The other thing to not here is to make sure you get the URN for your form correct!

Deploy and Debug Fun

At this point you should be ready to go!  You should be able to just hit F5 and test your workflow!

No comments: