zondag 6 februari 2011

Provisioning InfoPath (XSN) forms

Provisioning InfoPath forms with WSP’s can be hard to get right at first.
What we used to do is: put as much as possible in the WSP’s. Add some extra steps in the site-installation manual to manual publish the forms using InfoPath designer.

You probably tried to use something like:
1 <elements xmlns="http://schemas.microsoft.com/sharepoint/">
2 <module name="DefaultForms" rootwebonly="FALSE" url="Lists/Forms">
3 <file path="DefaultForms\TestForm.xsn" type="GhostableInLibrary" url="TestForm.xsn"/>
4 </module>
5 </elements>

But if you just put the XSN files in a module and deploy it to a Form-library like this, or just upload the xsn file to the library, the Info Path form will not be able to render (error: form is not browser enabled).
What you have to do to fix this is adding some extra properties:
1 <elements xmlns="http://schemas.microsoft.com/sharepoint/">
2 <module 
3 name="DefaultFormulieren" 
4 rootwebonly="FALSE" 
5 url="Lists/Forms">
6 <file path="DefaultForms\TestForm.xsn" 
7 type="GhostableInLibrary" url="TestForm.xsn">
8 <property name="ContentTypeId"
9 value="0x01010100B0996FC557D4AE4896B23DFBD45FFF5C"/>
10 <property name="ContentType" value="Form"/>
11 <property name="vti_contenttag" type="string" 
12 value="{13872FC0-7DF2-4C5F-98F4-6F018A0F8A66},2,1"/>
13 <property name="ipfs_streamhash" type="string"
14 value="u+Z+9oSpboLO+KfE7V3NmgN0DfxlgCQB0/R8/S3pVBM="/>  
15 </file>
16 </module>
17 </elements>

ContentTypeId and ContentType are self explaining, but how to find the vti_contenttag and ipfs_streamhash?
I’m not sure if there’s a way to calculate these values yourself, but this is how I do it:
I open the form in InfoPath-designer and publish it to a SharePoint site. The next step is to create a WSP from the existing site.

If it’s a publishing site you cannot in a normal way access the ‘save site as template’ page. So you should browse to / _layouts/savetmpl.aspx. There's no shame in doing this (or in forgetting), just remeber that it's hidden for a reason!

Make sure ‘Include content’ is selected.
Download the WSP and rename to .cab
Now you can extract this file with (for example) winrar.
Browse to the just extracted files.

Open the Modules folder
Under 'files' you’ll find the XSN file (under a subfolder with the name of the library), I always use this file to be absolutely sure it’s exactly the same as when a user publishes the original XSN with infopath.

Go back to the root folder of your extracted WSP and open the 'propertybag' folder.
In this folder open the elements.xml.

Find the File tag for your XSN file. (just search for .xsn).

Here you’ll find the vti_contenttag and ipfs_streamhash values. You can just add these to your module, since SharePoint itself figures out if values are fields or need to be set to the propertybag.


That's it.

1 opmerking:

  1. Hi Benjamin,

    Nice post, i did all what you said, but i am getting an error while opening the list form as, you do not have permission to open this form. As this is customized list form, so security tab does not come, from where i can make the security to domain level.Please help

    BeantwoordenVerwijderen