Auto-Fill from List Box

This came up on an internal mailing list:

We have a secondary data source that holds a list of entries; part of the data in the list - a name field - is used to populate the items in a listbox in the view. When the user selects an item in the list, I want the rest of the data from that entry to be used to populate the form's main data source.

Great scenario! It actually can be done with a combination of rules and filters (though I admit it’s not obvious), so you don’t have to write code for it.


For this example, I will assume you have a form with:

  • A secondary data source with repeating items (for example, a list of people each with an ID, Name and Age)

  • A dropdown that lists the values in the data source (e.g. displays the name of each person and uses the ID as the value)

  • A set of nodes in your main data source that should be auto-populated when the dropdown changes (e.g. An age textbox that gets the age of the person selected in the dropdown)

What you’ll need to do is create a rule on the dropdown. The rule will set the value in the textbox by filtering the corresponding value in the secondary data source down to one that matches the dropdown selection.


Here’s how to do it:

  1. Double click the dropdown to open its Properties Dialog (it can be bound to a node in the main data source or in a secondary one, it doesn’t matter)
  2. Click the Rules button

  3. Click Add to add a rule

  4. Click Add Action

  5. For the Action, select Set a field’s Value

  6. For the Field, select the selectedAge node or whatever node you want to set automatically

  7. For the Value, click the Fx button

  8. In the Formula dialog, click Insert Field or Group

  9. In the Data Source dialog, select the secondary data source and then the age node or whatever node you want copy over

  10. Click the Filter button

  11. In the Filter dialog, set the filter to “secondary-data-source-ID is equal to main-data-source-ID”

  12. OK out of all dialogs, you’re done.

Note that if your dropdown is inside a repeating section/table, then you will need to manually adjust the value in the formula dialog after step 11 to use the “current()” function so the filter works correctly.


Comments (8)

  1. RD says:


    I got the same problem and unfortunately my drop-down is inside a repeating section….

    So, how do you actually use the "current()" function? Because I cannot find a way to do manual editing?

    Thanks in advance…


  2. Joshua Bell [MSFT] says:

    To enter an expression manually, select "The expression" in the first drop-down of the filter building dialog (at step 11).

    For more help on the current() function, look at the blog entry (September 13th)

  3. I like InfoPath, but was a bit reserved at first… and as a developer I have found InfoPath immensely…

  4. SRINIVAS DEVI says:

    HI SIR,


  5. George Ceaser says:

    So seriously — how do I do this?

    "In the Filter dialog, set the filter to “secondary-data-source-ID is equal to main-data-source-ID”

    I am using infopath 2010 and have server issues like -1) when I double click a field I do not get its properties 2) In the properties window I can find there is no "Rules" button – the only rules button is on the Ribbon.   Then of course the fact that the fiter dialog makes me pick fields.  If I choose the option to have it let me enter an expression and enter "secondary-data-source-ID is equal to main-data-source-ID” EXACTLY as it is here minus the quotation marks it tells me I have an error.

  6. Nitin says:

    Is there any way to implement the

    Autofill for fields, like google search, using data from SQL table?

Skip to main content