Can I do a Filtered Data Connection Query on an InfoPath form?
Posted on 2008-10-29
Inside an InfoPath form, is it possible to read data from a data connection based on information that has been entered by the user?
An example of this is having a drop down box where the user selects a category (i.e., frozen food, canned vegetables, magazines, etc). After the user has made his choice, a select group of products will then be read from a data connection and be made available in a second drop down list. As another example, if the user selected Canned Vegetables, he would see Green Giant Whole Kernel Corn, Libbys Sliced Carrots, Del Monte Sweet Peas, etc. and not see any Frozen Food or Magazines as choices.
I know it can be done like this using Visual Basic and C# programming using Visual Studio but I want to do this simple thing using SharePoint alone.
The first drop down box is no problem. We have similar scenarios going already where we are reading from SharePoint lists over a web service data connection. But in this case we would be applying a filter; currently we pull all data from the SharePoint lists.
Also there is a question of timing. I cant poll the data connection until after the user has responded to the first data field. On the properties of the data connections, I see only the option to get the data at the time the form is loaded. This tells me that the only option I have is to add a button that queries the data connection after the selection is made. That would be my event.
But, from what I see, using a button to query the data connection still brings across the full set of data from the SharePoint list because there appears to be no way to pass an argument as a filter to the data connection.
Hopefully, there is some "trick" here that is not obvious to me. I thank you for any insights you can share with me.