Share via


SharePoint 2010 Workflow with InfoPath Association Form

Visual Studio 2010 provides a very useful method to help us to package the SharePoint 2010 artifacts and features as package and allow us to hit F5 to debug our code. All is well but sometimes you felt you do not have full control over how the feature is attributed and how the package is assembled.

I created a workflow with association form and I could not get the InfoPath form registered and it took quite a while for me to figure it out so I’d like to share some points here so this might benefit someone who is struggling with the same issue.

Step 1. Create a InfoPath form to be used as association form

  • Make it browser enabled form
  • Make the data connection submit to Host
  • Publish the form to a file folder
  • Write down the InfoPath form ID (File->Form Template Properties), something looks like urn:schemas-microsoft-com:office:infopath:MetadataUpdateInstruction:-myXSD-2010-05-26T20-35-57
  • Export the InfoPath form (Publish –> Export Source Files) to a folder, run xsd.exe against the myschema.xsd to generate a C# or VB class file

Step 2. Create your workflow project

  • Choose workflow project template
  • Make necessary changes to the name of the workflow and feature
  • Make sure it can be compiled and deployed

Step 3. Add InfoPath form into project

  • Add a module to the project named as Forms
  • Add the published InfoPath form into this module
  • In your feature design surface, make sure all artifacts you needed in included in the feature
  • Click on the Manifest, click on Edit Options, add <Property Key=”RegisterForms” Value=”Forms\*.xsn” />
  • In workflow Elements.xml, add AssociationUrl=”_layouts/CstWrkflIP.aspx” attribute to workflow node, uncomment the <Association_FormURN></Association_FormURN> line and add the InfoPath form ID in between
  • Make sure the feature receiver is specified – without this the InfoPath form never got registered
  • And you should see something similar to the following image:

image

Step 4. Reading Association form data inside code

  • The submitted InfoPath form is serialized as string and you can get it from workflowProperties.AssociationData property
  • Add the generated C# code file generated in step 1 to project
  • The following code snippet can be used to get your association data xml

image

Comments

  • Anonymous
    July 14, 2010
    Is the infopath version 2010?

  • Anonymous
    August 16, 2010
    Whoa great post. I had done everything except adding the RegisterForms property. I'm rather surprised that there's so little info from MS about adding InfoPath forms to 2010 Wf projects. Took me a while till I found your page.

  • Anonymous
    September 01, 2010
    How to use use infopath task edit form into Share point workflow 2010

  • Anonymous
    September 01, 2010
    How to use infopath task edit form in Sharepoint 2010 workflow.... Kind send the details ... my mail id:sureshkumarlaksmi@gmail.com

  • Anonymous
    September 01, 2010
    How to use infopath task edit form in Sharepoint 2010 workflow... how to configur in Feature Xml file ,element file, where to add published infopath form? sureshkumarlaksmi@gmail.com

  • Anonymous
    September 16, 2010
    Thanks a ton John :-) Check below link also if working with Infopath task edit form with SharePoint 2010 and visual studio 2010 sequential workflow social.technet.microsoft.com/.../729f0ccb-6651-403e-95e1-136f28edf5f5

  • Anonymous
    December 30, 2010
    Hi there, Can you explain what you mean by: •Make sure the feature receiver is specified – without this the InfoPath form never got registered Thanks, Jupi