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=12.0.0.0, 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.

sitesettings

Select the WebPart’s Gallery.

webpartssitesettings

Click New.

xmlwebpartnew

Find the Microsoft.Office.InfoPath.Server.Controls.XmlFormView. Select the checkbox beside it and click the populate Gallery button.

xmlformwebpartadd

Step Three (Optional) – Change the WebPart Details:

Now let’s change the webpart’s properties because the name isn’t very helpful (XmlFormView).

xmleditwebpart

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.

xmlwebpartupdate

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 :)).

xmladdwebpart

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.

xmlwebpartclosed

Modify it’s properties and add the following three important things:

  1. Change the EditingStatus to Edited or Init (as desired) since Closed probably isn’t what you want.
  2. 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.
  3. 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.

xmlformviewproperties

And voila the form should display like you always wanted.

xmlformviewerinpage1

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),
Richard Harbridge

Advertisements
Explore posts in the same categories: Administration, Feature, Free Stuff, Reference, SharePoint 2007, WebPart

Tags: ,

You can comment below, or link to this permanent URL from your own site.

27 Comments on “InfoPath Webpart – Host InfoPath Templates in WebPartPages – Free”

  1. alecpojidaev Says:

    Thanks.
    BTW It’s not that hard to get right quotes. All what you need is replace all (“) with (")

  2. alecpojidaev Says:

    Ok one more try. To prevent it to be automaticly converted i’ll use spaces (& q u o t 😉

  3. alecpojidaev Says:

    Finally: (& q u o t; )

  4. rharbridge Says:

    It’s true! But believe it or not my dumb admin console automatically changes &quo t; (ignore space) characters to the broken wordpress ones.

    I just need a new bloggin platform sometime haha.

  5. eariel Says:

    Thanks!!!

    Great post! Very usefull!

  6. Nimi Kaul Says:

    Hi,

    Whenever I use this web part to display a form, the page does not follow the styles and colors of the master page. Any idea why and how to get this done?

  7. rharbridge Says:

    I’m not sure I understand. The form’s look and feel is completely customized in InfoPath. The webpart’s styles can be inherited from the CSS used in the SharePoint site, but the form itself would be seperate.

    Hope this helps,
    Richard

  8. Nimi Kaul Says:

    WHat i am trying to say is that the page is over-riding the site’s style. My complete portal has been customized to apper in Orange and green but this page always appears in blue. i tried changing the theme of the site but the page still appears only in blue.

  9. rharbridge Says:

    Interesting. From the tests I have just performed I am not able to reproduce this issue.

    The left and top of a the default masterpage colors will change based on the theme you choose and from everything I can find this will not be effected by the InfoPath webpart as it simply displays the XSN using form services.

    My orange and green (citris) theme was uneffected by use of this webpart method described above. However if I chose to use the built in form services page it would have no top or left navigation (since it takes over the entire real estate of the page).

    Would it be possible for you to post a screen shot of your issue?

  10. rharbridge Says:

    (Deleted last comment for security.)

    Will look into it shortly. 🙂

  11. rharbridge Says:

    Hey Nimi,

    It looks like the way you did the styling is causing the issue. Try opening the opportunity page in an object explorer like IE developer toolbar as well as one of the properly styled pages. You will notice the HTML is slightly different. I believe this is what is causing your issue.

    If you go to your site settings page you can see that you don’t overwrite all the styles completely. See the left blue bar next to your green one?

    Play with the CSS and use a dom explorer like firebug or IE developer toolbar and you should be able to correct it. Branding SharePoint can be a finicky thing. 🙂

  12. Nimi Kaul Says:

    Thanx a lot for your help and time!

  13. JD Says:

    This might be a stupid question, but does enabling this webpart allow users to fill out the form without the InfoPath software? I run IT for a small business and want to transition to digital forms on SharePoint, but most of my users don’t have InfoPath. Thanks.

  14. rharbridge Says:

    That’s a great question. This does mean you won’t need an InfoPath client for each user. However it does mean you need SharePoint Enterprise CAL’s and Enterprise features because that contains InfoPath Form Services which this utilizes.

    The primary selling point for the “InfoPath Form Services” enterprise feature of SharePoint is to remove the need for readers to have the InfoPath client.

    The enterprise features of SharePoint give alot more as well such as Excel Web Services which removes the need to have excel in order to view excel documents, and the BDC which connects data and displays it powerfully in SharePoint.

    • JD Says:

      Ok, fantastic. Would this process be roughly the same for SharePoint ’03 or is it even possible?

      • rharbridge Says:

        You could do it with SharePoint 2003 and InfoPath Form Server which is a seperate server product. This server product is rolled into SharePoint 2007 Enterprise (basically).

        It is important to note that while 2003 forms can be browser enabled etc, I do think you need/should have InfoPath 2007 for those designing the forms.

      • rharbridge Says:

        Err (to add on previous comment and clarify) – You will need to do something like this if you are using InfoPath 2003 or your forms were designed in InfoPath 2003 then you will need to ensure they are browser enabled (http://blogs.msdn.com/infopath/archive/2006/06/08/622340.aspx). This is how they are able to be loaded in Forms Server or Form Services.

        Hope this helps,
        Richard

  15. Sumeet Gandhi Says:

    Hi,

    Good to see the post. I have one query. I have created and deployed a form on the server. Now the form contains some rich text boxes. Now as soon as we click into these boxes a toolbox having lot of formatting controls will appear and will allow us to do the formatting. Now my requirement is that I need to customize that dynamic toolbar which is provided by InfoPath. Any idea? what can i work into in order to get this customized?

    Quick help would be appreciated.

    Thanks
    Sumeet Gandhi

    • rharbridge Says:

      This would require custom code. The control itself is an InfoPath control so you can’t really modify the toolbar it uses. That said you can create your own version of the control that can have anything you want using custom code.

      You could also do something simpler like creating buttons that change conditional formatting on a rich text box. This way you could change many things about the content without necessarily using the built in toolbar for the Rich Text.

      Hope this helps,
      Richard Harbridge

  16. aobial Says:

    Hi! is this infopath webpart is for MOSS only? can i possibly use this for wss 3.0 only????

  17. rharbridge Says:

    Yes. This uses InfoPath Form Services which is a part of the Microsoft Office SharePoint Server enterprise license.

  18. Prasad Says:

    Hi,

    I added the webpart as you mentioned and it works fine.
    But the problem is if I use Ubuntu to open the sharepoint site, when I go to the page where the webpart is located, it gives an error

    Is there any way to overcome that?
    Thanks and waiting for a reply.


  19. Unfortunately I haven’t actually ever used Ubuntu 😦

    My Linux related experience is pretty thin. I would recommend posting this question to the SharePoint forums. This part is built by Microsoft, so if there is an issue it can at least be logged by Microsoft as something that they can look at/resolve.

    Hope this helps,
    Richard Harbridge

  20. Fraser Says:

    Great post and I’ve got the webpart page submitting a response to the form library. So the next step I can’t fugure out is how to set the library up so that when I edit an existing item it opens up into the webpart page instead of the defaut inforpath page/

    • rharbridge Says:

      There are a couple ways to go about doing what you suggest here. A simple one might be to just use a dataformwebpart (or sometimes called the dataviewwebpart) in SharePoint Designer and set it up with custom buttons/image links that refer to the appropriate page with this webpart.

      I know there are other (probably better ways) but as I am in between 3 things right now I figure a brief response is better than no response. 🙂 Hope this helps,
      Richard

  21. Chuck Duncan Says:

    I have a more basic problem: After carefully setting up the SafeControl in the web.config, I am unable to see the entry after selecting NEW in the Web Part Gallery. This raises the question in my mind: how is Sharepoint supposed to find the dll since it is in Program Files\Microsoft Office Servers\12.0\bin? Does Sharepoint automatically look there? I can’t think of another reason why it wouldn’t show up.
    Thanks in advance 🙂

  22. rharbridge Says:

    You will have to forgive me (I am doing a bunch of other things right now), but my best guess is that perhaps you haven’t performed an IISReset, or application pool reset so that it shows up?

    Best guess off the top of my head,
    Richard


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: