Tags

The SharePoint list data connection in InfoPath is a great declarative way to bring in data from a SharePoint list, but it does have some limitations.  For those willing to put in a little extra effort, there’s much more that can be done with SharePoint lists: you can bind to views based on these lists. Here are the steps for creating the connection to a list view.

1. Go to the view and click “Edit View” Link

2. Copy the List={GUID}&View = {ViewGUID} portion of the URL and paste this into a buffer like a Notepad window.

3. In Notepad, create the following URL (the blue portion us taken from the step 1 URL, and the red portion must be added.

http://contoso/sites/sales/_vti_bin/owssvr.dll?Cmd=Display&List={GUID}&View={ViewGUID}&XMLDATA=TRUE&noredirect=true

This will return an xml file that can be used in an XML file data connection, as if it came from a file system.  After this, you can use the URL as the location of an XML data file when creating a data connection.

 

Two caveats:
– Form users must have read access to the SharePoint list.
– During creation of the data connection, do not include the file in the form template, as it should be dynamically generated from the SharePoint list.

owssvr.dll – Beware of multiple selection lookups

owssvr.dll can be used in InfoPath projects to provide filtered or cascading drop down lists. Use an XML datasource – the syntax is http://yourserver/yourweb/_vti_bin/owssvr.dll?Cmd=Display&List={guid}&XMLDATA=TRUE.

However, beware if your list contains a lookupfield that allows multiple selections. If you have this, then the above syntax will return an invalid XML, or a blank data set.

List contains lookup field(s) with single selection – syntax works.
List contains lookup field(s) with multiple selection – syntax fails.

Advertisements