17 April 2007

[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…

 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Tim said:

Sorry, but this does not work. The values that are not from the top-category remain in the dropdownlist.

21 June 07 at 7:29 AM
# Daniel said:

I've found the same as Tim. This method does automatically select one of the matches from the secondary field, but it doesnt stop displaying the fields that dont match.

I'm using a Region (eg, Aus, USA, UK) as my primary and City (eg, Syd, Melb, Omaha, London) as my secondary.

If I find a solution will post.

26 July 07 at 2:12 AM
# Allistair said:

Actually, it works fine, for my context. It matches DOB field with an ID attribute, and populates a field nicely matching data.

Nice one, Wael, thanks for taking the trouble to share this.

27 August 07 at 11:08 AM
# Wael A. Kabli said:

Thanks all for your comments,,,

the guys are right about the auto select

the filter here doesn't narrow down the list as much as it do an auto-select from the list

27 August 07 at 12:24 PM
# Wael A. Kabli said:

ok i think the problem that you are all facing is solved via web Services,,,

so what can you do is actually,

do a web service that:

- takes a parameter,

- Do Filtering

- return List

by this you will solve the issue you are all talkiung about

28 August 07 at 7:26 AM
# Stacey said:

Actually, this works wonderfully.  And the filter works as expected.  Works great for cascading dropdownlists inside repeating sections as well!  In fact, this is the only solution I have found after 2 and 1/2 days digging around that actually solved my problem.

16 October 08 at 4:22 PM
# Wael A. Kabli said:

Stacy,

Am glad that worked for you :D

16 October 08 at 5:04 PM
# Nancy said:

Thank you for this GREAT post.

God bless you. All I can say.

29 October 08 at 11:37 AM
# Mike said:

I have tried to apply this solution to a new form I am working on and cannot get it to work.   For some reason I am only getting the first entry in the external data source being returned.

I have a sharepoint list:

  Location              Slot

    X1                         10

    X1                          20

    X1                         30

    Y1                          AA

    Y1                          BB

When I use the above method to filter on Location to return all Slots, if I choose Location X1 I only get 10 returned.   I need all matches returnee to the slot drop-down list.   any suggestions?

07 November 08 at 11:03 AM
# Houssam said:

it is not working - can anyone send me a working files to deepminds@gmail.com

thanks

12 May 09 at 5:06 AM
# dips23 said:

Hello sir ,

its a really nice technique to filtering data on web IP form !!! but i am not getting result !!

i did all the steps three times but i m not able to see matches value !!!

what should be the problem !!! can u please help me out !!!

thanks & regards,

Dipti Chhatrapati

13 July 09 at 6:22 AM

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 

  
Enter Code Here: Required

About Wael A. Kabli

I started working for Microsoft in 2006 after I graduated from King Fahd University of Petroleum and Minerals as a Software Engineer. Since then, I have joined Microsoft Consulting Services and started my career as an Information Worker and Application Development Consultant. A major portion of my work is helping our customers deploy and accelerate our technology adoption such as Microsoft Office SharePoint Server and .Net Framework. https://careers.microsoft.com/careers/en/gbl/ProfileWaelWE.aspx
Page view tracker