Pre-filtering large SharePoint lists in InfoPath using WSS's owssvr.dll

by S.Y.M. Wong-A-Ton

Learn how you can take advantage of Windows SharePoint Services' owssvr.dll to filter a long or large list of data in a SharePoint list before the data is returned to an InfoPath form and used to populate InfoPath controls.

Sometimes ideas are worth sharing as is the case with this one that someone in the forum came up with just last week.

One of the reasons I like to visit the SharePoint forums is that many people come together there, and sometimes great ideas are born. Such was the case when someone using the alias The_Holy_One came up with a brilliant idea to extend a previously posted solution by the InfoPath Team and was trying to create a dynamic secondary data connection in InfoPath by changing the URL to an XML file.

The solution posted by the InfoPath Team made use of the owssvr.dll DLL to populate data in InfoPath using SharePoint list views.

The beauty of using the owssvr.dll DLL is that you can pass a parameter named FilterFieldn to specify a name in the SharePoint list to filter on and a parameter named FilterValuen to specify the value to filter on.

The disadvantage of not using the preceding two parameters and the owssvr.dll DLL is that if you have a SharePoint list that contains many items (over 1000 for example), and you want to populate a control in InfoPath using a data connection to this SharePoint list, it will have an impact on the performance of the InfoPath form, that is, it will take a long while to load all of that data from the large SharePoint list into InfoPath.

The solution that The_Holy_One came up with, was to pre-filter the data on the SharePoint server and only retrieve those items from the SharePoint list that were selected by the user in the InfoPath form. To do this, The_Holy_One had to find a way to:

  1. Set the FilterValuen parameter based on the value of a field on the InfoPath form.
  2. Dynamically change the URL of the data connection to the XML "file" returned by owssvr.dll.

Note: The owssvr.dll DLL returns XML data that can be used in InfoPath to populate controls.

The InfoPath object model offers a class named FileQueryConnection, which you can use in code to specify the URL to an XML file. And the nice thing is that you can dynamically change the URL of the XML file for the FileQueryConnection object as a previous InfoPath – SharePoint article I wrote shows you how to do.

 Subscribe (RSS | Email)

Related Posts

Comments to this post were closed 30 days after it was published.

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. Usage of techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.

Working with InfoPath