InfoPath Webpart – Host InfoPath Templates in WebPartPages – Free
First of all why? If for nothing else there are products that are sold out there that literally cost hundreds of dollars that do exactly what I am going to describe in this post (and in some cases have extra limitations).
If you want to host an InfoPath form template embedded in a SharePoint webpart page it is a fairly easy process and I noticed a few glitches or extra steps in the articles I found on this so I figured I would iterate my own perspective.
There is a webpart included in the Enterprise version of Microsoft Office SharePoint Server. The webpart is called the XmlFormView: http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.server.controls.xmlformview.aspx. It is powerful, simple, and relatively easy to use. However it is not in the webpart gallery by default there are a few steps you need to do to enable this nice little webpart in your SharePoint web application and then the targeted site collection.
Step One – Modify the Web.Config:
The first step is to modify the web.config file with an extra safe control entry. (Web.config files are stored typically in “C:\Inetpub\wwwroot\wss\VirtualDirectories\PORT NUMBER or host header name” (Back up the web.config first if you want, but this is a pretty safe change.) The entry you are going to add is shown below and goes in the <SafeControls> section (in case you didn’t guess that :P):
<SafeControl Assembly=“Microsoft.Office.InfoPath.Server, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.Office.InfoPath.Server.Controls” TypeName=”*” Safe=”True” />
NOTE BEFORE YOU COPY – WordPress messes with my ” characters I think, so make sure you either type this out personally, or at least check it before copying and pasting into your web.config (otherwise you’ll get a server error.)
Save the web.config file after you change it and load up the target site collection in a browser.
Step Two – Make the WebPart Available For Use:
Access Site Settings for the root of the site collection.
Select the WebPart’s Gallery.
Find the Microsoft.Office.InfoPath.Server.Controls.XmlFormView. Select the checkbox beside it and click the populate Gallery button.
Step Three (Optional) – Change the WebPart Details:
Now let’s change the webpart’s properties because the name isn’t very helpful (XmlFormView).
Just put in whatever details you want. This is also where you should probably set this webpart up so that only certain groups can add it who have the training and knowledge to do so.
Step Four – Add the WebPart to a Page and Configure It:
Now all we have to do is navigate to a page and add the webpart. Simply click the gold add webpart band on the target page when in edit mode and scroll down to the webpart we added (and renamed :)).
After clicking Add you will recieve an error. Don’t worry about it, just hit close. The webpart will show on the page like so.
Modify it’s properties and add the following three important things:
- Change the EditingStatus to Edited or Init (as desired) since Closed probably isn’t what you want.
- Set the XSNLocation to wherever your xsn form is being stored. In my example here I have deployed it to a form libary called Library.
- Set the save location for where the form should save to. In my example I actually have the option DisableSave in there so this isn’t necessary (since I am saying to disable the ability to save from this part). Remember your xsn’s submission rules normally dictate where the form will be saved and stored.
And voila the form should display like you always wanted.
Step Six – After Effects:
Tell your boss you just saved the company several hundred dollars and did an amazing job.
Hope this helps someone out there (and doesn’t offend any of the ISV/product companies who do something like this),