Friday, February 12, 2010

InfoPath form in a WebPart

How to create a embedded InfoPath form in a normal web part page or site. This is how it can look like:

clip_image001

Change the web.config of the web application and add this line in the section <SafeControls>

<SafeControl Assembly="Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.Office.InfoPath.Server.Controls" TypeName="*" Safe="True" />

Go to the site where you want to show the InfoPath forms and activate the site settings

clip_image002

Click on Web Parts

clip_image003

Click on New

clip_image004

Activate the InfoPath XmlFormView Assembly

clip_image005

And click on Populate Gallery

Now you can create a new site or web part page. The following example shows how to do this with webpart pages. Please keep in mind to use the link http://url/site?contents=1 to remove/deactivate the XmlFormView WebPart.

clip_image006

Create a new Page

clip_image007

Type the Title, URL an choose a Web Part Page layout to create. Open the Page and edit

clip_image008

Add a web Part

clip_image009

Add the XmlFormView WebPart

clip_image010

The WebPart is not configured. Press close

clip_image011

This is the result. This web part is not going to work. We need to add an other one but first disable this one.

In the page library select the webpart page and edit the properties

clip_image012

clip_image013

Click on "Open Web Part Page in maintenance view"

clip_image014

Select the web part and click on close

Go back to edit the web part page and add a web part

clip_image009[1]

Select the XmlFormView web part again. This time you get the following message

clip_image015

Now modify the web part

clip_image016

Open the Data Binding properties

clip_image017

You need to have a deployed InfoPath form (see XsnLocation) and you also need a library to store the edited forms (SaveLocation). Please create them before

e.g. http://alegri-intranet/sites/site0001/FormServerTemplates/Project.xsn

e.g. http://alegri-intranet/sites/site0001/Project%20Status

Press Apply

clip_image018

Now we need to delete the fist web part. Edit the page in the page library

clip_image012[1]

clip_image013[1]

Click on "Open Web Part Page in maintenance view"

clip_image019

Select the right web part and click on delete

That's it.

No comments: