SharePoint XSN provisionning with WSP - Fiks IT

Fiks IT

Everything began from nothing.

Breaking News

Post Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Friday, 17 February 2017

SharePoint XSN provisionning with WSP

it's not very simple to package a form xsn in the wsp solution, specialy if you want to do a provisionning.

You probably tried to use something like:
1 <elements xmlns="">
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="">
 2   <module 
 3        name="DefaultFormulieren" 
 4        rootwebonly="FALSE" 
 5        url="Lists/Forms">
 6      <file path="DefaultForms\myform.xsn" 
 7            type="GhostableInLibrary" url="TestForm.xsn">
 8        <property name="ContentTypeId"
 9                  value="XXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
10        <property name="ContentType" value="Form"/>
11        <property name="vti_contenttag" type="string" 
12                  value="{xxxxxxxxxxxxxxxxxxxxxxxxx},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?

  1.  open the form in InfoPath-designer and publish it to a SharePoint site.
  2.  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.

No comments:

Post a comment

Post Top Ad

Responsive Ads Here