Tuesday, April 03, 2007

Consuming data from a SharePoint list in InfoPath and using data connection files

In the previous post, I showed how you can create and publish a browser-enabled InfoPath form. In this post, I will show how you can consume data from a SharePoint list.

First create a new custom list in the SharePoint site where you published the InfoPath template and give it the name Functions. Add a number of items to this list for defining the different job functions - e.g. architect, analyst, system engineer and developer. Open your InfoPath form in design mode and add a new data connection. Select "Create new connection to receive data" and type "XML document". Specify the address for the XML file - http://moss/sitedirectory/dummy2/_vti_bin/owssvr.dll?Cmd=Display&List=GUID&XMLDATA=TRUE - in this URL you will need to replace GUID with the Id of your list. You can actually find this Id by going to the list settings and using a part of the URL. Another thing you can use is the SPCAMLViewer tool.

 

Owssvr.dll is actually one of the SharePoint RPC methods - (for more info check out FrontPage RPCs are here to stay, too..., SharePoint and RPCs ... and they are also used for some other things such as Creating webpartpages. For a detailed discussion about how you can consume data from a SharePoint list (even using SharePoint views) in InfoPath - check out Populating form data from SharePoint list views

 

Make sure that you choose the option "Do not include the file in the form template" when using the data connection wizard. Now, you can convert this data connection to a data connection file and store the settings in a Data Connection library which is a new type of SharePoint document library for storing connection files. Use the Convert option in the Data Connection dialog.  A contributor can upload connection definitions but these need to be approved before other users can use them. There also is a Centrally Managed Connection Library which has some advantages:

  • Use data connections across site collections
  •  Anyone can read the CMCL (no extra security settings needed 
  • But … they need to be deployed by an administrator (this is also more secure)

Now, you can finally publish the form again. You will need to use these Data Connection libraries to work around the multihop delegation issues which you have when deploying InfoPath browser-enabled forms - check out Using webservices in browser-enabled forms with InfoPath 2007 Forms Services

Resources:

 

No comments: