October 2011 - Posts - Mel Balsamo

InfoPath Dev

This Blog


Mel Balsamo

October 2011 - Posts

  • Show unique rows in a secondary repeating data source table - no code!

    When designing an InfoPath form that integrates with a secondary data source such as a SharePoint list, data retrieved from SQL, or a simple XML document – you may find yourself needing to hide rows that have the same value/s as that in your main data source.

    There might already be written blogs out there demonstrating techniques on how to do this such as Greg’s and Matt’s – both show different techniques on how to filter a dropdown list showing only unique selections; but I haven’t been able to find an exact article on how to hide the entire row in a repeating table coming from my secondary data source itself.

    In a recent project, I’ve used a technique that does just this and it really is so simple so it might be worth a share. Oh, and take note --- this works like a charm using just one conditional formatting, no code at all! Interested? Follow along…

    To simulate the scenario, let’s create an XML document that lists some fruits:

    <?xml version="1.0" encoding="UTF-8"?>


    We’ll use this as our secondary data source. Save it as an XML file.

    We’ll then design a simple InfoPath form template, adding the XML file as a secondary receive data connection that automatically retrieves data on form open – we’ll call it “Fruits”.


    This should be displayed in the Fields task pane like so:


    And then we’ll add the main data source:


    Next, drag the main data source Item group as a repeating table on the canvas, as well as the item repeating group from the XML secondary data source – add headings to differentiate the two sources, like so:


    We’ll now add the key ingredient!

    First, select the item repeating group from Fruits (Secondary) data source – this is where we’ll add the conditional formatting. Display the Rules by clicking Manage Rules under the Home tab and once displayed, click New > Formatting.

    On the Condition window, leave the first and the second dropdown selections to the item field of the Fruits (Secondary) data source and as “is equal to”, respectively; then on the third dropdown, choose “Select a field or group…”


    Select the Fruit field from the main data source.


    Click OK as many times needed to close all dialog boxes and then check the Hide this control box. Your conditional formatting rule should look similar to this:


    And now, the fun part – testing your form! On preview mode, it should look like this:


    Begin inserting item/s in the main data source and see for yourself, how simple it is to hide those secondary data source rows that has matching values in the main data source!


    Have I mentioned it’s simple? Smile

Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.