Wednesday, June 10, 2009

Getting a client side created InfoPath 2007 form in to a InfoPath Visual Studio project

Do you have an InfoPath form that was created in the InfoPath client and now you want to add it to a Visual Studio InfoPath project?

Here are the basic steps.. Follow along kids.

  1. Extract the source files from your client side form in to a directory called ClientSource. (you should know how to do this)
  2. Create a new InfoPath project in Visual Studio
  3. Close the open xsf file in Visual Studio
  4. Delete all the files under InfoPath Form Template directory in the Visual Studio solution
  5. In the ClientSource directory, edit the manifest.xsf file in NotePad++ or your favorite text editor and make the following changes.
    1. Delete the attributes "publishUrl and "trustLevel" (if exists) of the xsf:DocumentClass element
    2. Delete the properties xsf:property name="componentId" and xsf:property name="xmlToEditName"
    3. Add the sibling <xsf2:managedCode projectPath="path to and including csproj" language="CSharp" version="2.0" enabled="yes"></xsf2:managedCode> under xsf:extensions/xsf:extension/xsf2:solutionDefinition/xsf2:offline
      1. Path to and including csproj, ex: "C:\infopathForms\myIPFormProj\myIPFormProj.csproj”
      2. language value could also be VisualBasic, if you have create a VB project.
    4. Add the attribute scriptLanguage="managedCode"as the first attribute of xsf:applicationParameters/xsf:solutionProperties
    5. Save your changes
  6. Open template.xml in a text editor and make the following change
  7. In your Visual Studio project, right click on InfoPath Form Template folder and choose Add >> Existing Item.
  8. Navigate to your ClientSource directory
  9. Change the object type dropdown to ALL Files (*.*)
  10. Select ALL the files in the directory and click ADD
    1. NOTE: you want to bring in all the files so that you bring in all your data connections, resource files, view styles…
  11. In Visual Studio double click on manifest.xsf
  12. When/If prompted to save changes and publish, blah blah blah… click OK
  13. Build your project

That’s it…

1 comment:

Anonymous said...

Great, it worked(I had to remove an extra node)... Thank you very much..