[InfoPath] How to filter data on IP web enabled

One of the famous pitfalls in InfoPath 2007 is thinking that it doesn't have the ability to filter while on web or incase of having web-enabled forms. The few coming line will explain this issue and why many fall into this confusion…

Scenario: if you enabled web compatibility in IP 2007 and try to do a lookup on a field from a data source, sometimes you need to filter the information you get from external data source…

Let's say you have the following data:

  • Desktop Problems
    • Hardware
    • Software
  • Network Problems
    • network cables
    • IP telephone

Filter: you want to filter the data you bind to your controls, let's say if you have two fields, you want to show in the first field Desktop Problems, the second field should show only hardware and software.

Problem: if you try and filter on a field and the web compatibilities, you will get the following message: "Filtering is not supported in browser –enabled form templates."

Workaround:

  • Go to control you consider as primary field that it will be the filter key…in this case "MainDataSource.Category"
  • Right click, properties and Add a rule on it ..
  • The rule should have the following:
    • Action: set a field's value
    • Field: set the destination field where you want to filter your data. In this case "MainDataSource.SubCategories"
    • Value: here you need to insert a field from the external data source such that the key field in your main data source is equal to the key field in the external data source. To do that do the following:
      • Here is the tricky part.
      • Click on the button (fx)…
      • Click on insert a field or a group
      • Choose the destination filed you want from the external data source. In this case "ExternalDataSource.SubCategories".
      • Click on the "Filter Data".
      • Click on Add
      • You have the format: <<Value>> <<Comparison>> <<Value>>
      • Choose: ExternalDataSource.KeyValue IsEqualTo MainDataSource.KeyValue
      • In this case: ExternalDataSource.Category IsEqualTo MainDataSource.Category
      • The click on "OK" Gazillion times. J

Go and Test…