Deploying the Browser enabled InfoPath Form template through feature


Few weeks back worked on an interesting case on which the customer is trying to Deploy an InfoPath form template to the SharePoint form library through feature and encounters an issue that he was unable to open the template in the Browser even after making sure that the template is browser enabled and the form library setting is changed to open the template in the Browser. We dig into this and found an interesting OOB Receiver Class which we can make use of it.

Customer has created a browser enabled InfoPath Form template and following are the scenario where it works and fails :

1. If customer directly publish the InfoPath form template from InfoPath client as a template for the SharePoint form library then they are able to open the template in the browser from the SharePoint Form library.

2. If customer directly publish the InfoPath form template from InfoPath client as a content type to the SharePoint then later if they associate the content type to the form library then it works.

3. If customer publish the InfoPath form template from InfoPath client to the Network location and uploads it to the central administration site then if he do an admin deployment from Central Admin to the SharePoint site collection (as a content type to the OOB “Form templates” library) then it works.

4. If customer publish the InfoPath form template from client to the Network location and provisions it through feature then they are unable to open the InfoPath form server template in Browser from the Form Library and it always opens the Form in the InfoPath client application.

During the investigation of the feature found that customer has a feature activated event in which he reads the XSN forms from the feature folder in the form of binary data and adding the form as a file to the “Forms” sub folder of the form library. Then through the “DocumentTemplate” property of the form library customer is setting the uploaded XSN form as the template to the form library. When he activates this feature the custom Form Server templates are set as the default template to create InfoPath forms in the form library. Customer have already Changed the Form Library settings to open the template in browser rather than the client application. But when he try to create new InfoPath form in the form library it opens the custom form server templates in the InfoPath Client application instead of opening it in the browser.

The only vast difference we see here is the way InfoPath server template has been added to the “Form” sub folder of the form library. When we read the Form server templates as binary and adds it as a file to the “Forms” sub folder of the Form library then actually the form server is not published (Not Registered and Activated) to the Site collection. We need to adapt the mechanism which InfoPath application implements while publishing form server templates to the Form Library of SharePoint site collection. We need to adapt the mechanism which InfoPath application implements while publishing form server templates to the Form Library of SharePoint site collection. I.e. We need to use the FormsService API to publish the Browser enabled Form template to the form library (Note : We can make use of the FormsServices.asmx OOB web service to do the same) 

The FormsService class in the Microsoft.Office.InfoPath.Server.dll has the methods and properties to publish (Register and Activate) form server template to the document library level or to the Site collection level as a content type.

So the conclusion is that we need to use the FormsService API to publish the Browser enabled form template to the form library instead of just reading it as a binary and adding it as a file to the Forms sub folder of the form Library.

When decided to replace the feature activated code to use the FormsServices API to Publish the Form template realized that we have an OOB feature receiver assembly called “Microsoft.Office.InfoPath.Server.Administration.XsnFeatureReceiver” which uses the FormsServices API to publish the InfoPath template to the form Library through feature. (luckily found 🙂 Ref : http://blah.winsmarts.com/2008-8-Deploying_InfoPath_2007_Forms_to_Forms_Server_-and-ndash_Properly.aspx).

OOB feature receiver Microsoft.Office.InfoPath.Server.Administration.XsnFeatureReceiver class in Microsoft.Office.InfoPath.Server.dll  which can be used to provision the form server template as a template to the Specific library or as a content type (I.e. Placing the template under “Forms Templates” library) to the specific site collection. If a custom feature has Form Server templates to deploy then you need to add this feature receiver DLL as receiver assembly so that the form server templates gets deployed properly with the XSN schema.


Skip to main content