Embedding InfoPath Form in SharePoint Page
Few weeks ago, I was punctuated to embed an InfoPath form in SharePoint page. Immediately, I though of creating a custom web part or using SharePoint Designer. But hold on, InfoPath has already provided us this facility. By the good worth of “NO CODE” development model, it is the sensible solution: XML Form View web part.
We initially need the following:
1. A Form Library in SharePoint site. In this paper, we will name our Form Library as Expense and our SharePoint site as Demonstration Portal.
2. A browser-enabled InfoPath form published to our Expense Form Library. We will use the Sample-Expense Report and name it as Expense Report.
By the same token, we could use an administrator-approved form template, plainly uploaded and activated through Manage Form Template facility in the Application Management of our SharePoint 3.0 Central Administration. And we will get a hold of the same results.
1. Upon completion of our two predetermined items, we going to add the following line in the <SafeControls> tag of the web.config file of our web application:
<SafeControl Assembly=”Microsoft.Office.InfoPath.Server, Version=188.8.131.52, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.Office.InfoPath.Server.Controls” TypeName=”*” Safe=”True” />
NOTE: The web.config file of our web application is located at C:\Inetpub\wwwroot\wss\
VirtualDirectories\web application port number.
2. Let us open our Demonstration Portal. Under Site Actions, click Site Settings.
3. In the Site Settings page, as illustrated below, click Web Part Gallery link.
4. In the Web Part Gallery page, click New. We will be redirected to the Web Part Gallery : New Web Parts facility.
5. In the Web Part Gallery : New Web Parts part, check Microsoft.Office.InfoPath.Server.Controls.XmlFormView. Then, click Populate Gallery. We will be redirected again to the Web Part Gallery page where we can verify the inclusion of XmlFormView.webpart. Below is the illustration.
6. At this instant, we will employ the web part to put on view our Expense Report form. Let us open our Expense Form Library.
7. In the Site Actions, click Edit Page. As illustrated below, the page will be set to Edit Mode.
8. Click the Add a Web Part link, and the Add Web Part to Main web page dialog will be displayed.
9. Check the XmlFormView, normally under miscellaneous section, then click OK. If we will be prompted by an error message of InfoPath, we have nothing to worry. Just click Close.
10. Now, we will modify our XmlFormView web part. To do this, click Edit, then Modify Shared Web Part.
11. As illustrated below, let us set the following items, then click OK.
a. Editing Status : Editing
b. Xsn Location : Please refer to the notations below.
NOTE: The Xsn Location varies on the publishing approach we have employed.
a. If we have published our form template directly to a specific Form Library, similar with our case, we can check the location from Site Actions, then Site Settings, then Site Libraries and Lists, then Customize Form Library, then click the corresponding Form Content Type, then Advance Settings, and we will have the URL of our form template. It is http://Server Name:Port Number/Form Library Name/forms/template.xsn.
b. If we have published, however, an administrator-approved form template through the Manage Form Template facility, we can check the location from Site Actions, then Site Settings, then Site Content Types, then the corresponding Form Template Name – it is normally under the Microsoft Office InfoPath section, then Advanced Settings, and we will have the URL of our form template. It is http://Server Name:Port Number/FormServerTemplates/Form Name.xsn.
12. As a final task, we will close the Expense list view, then Exit Edit Mode to have the final output.
I hope it will help you!