InfoPath with SharePoint 2010 : Dynamically Populate a Repeating Table – Set Up the Initial Form

Scenario/Problem: You need to set up the initial form.

 

Solution: The initial form contains at least a selection field and a repeating group of fields to populate. The selection field can be populated by a data source if required. A secondary data source exists to populate the repeating table.

To set up the initial form, follow these steps:

1.
Design a new form in InfoPath Designer 2010.

2.
Add a drop-down list control to the form and name the field accordingly. (For the example, I used Selection.)

3.
Add a repeating table to the form, selecting the number of columns as appropriate. Rename the fields accordingly. For this example, I kept the default of three columns and renamed only the repeating group to groupRepeat. Your form should now look similar to Figure 1.

Figure 1. Adding the controls to the form performs the initial form setup.


4.
Add a data connection to retrieve data for the selection field. Modify the selection field accordingly. For this example, I am retrieving Regions from a SharePoint list.

5.
Add a data connection to retrieve data for the population of the repeating table; let’s call this the dependent data source. For this example, I am retrieving Offices from a SharePoint list.

6.
Add a rule on the selection field such that when the selection changes you set the query field and query the dependent data source that you will use to populate the repeating table. For this example, I set the Region query field of the Offices data source to the selection field, as shown in Figure 2, to retrieve the related data.

Figure 2. Setting the query field value retrieves the related data.


7.
For testing purposes, drag the repeating group of the dependent data source onto the form.

8.
Preview the form and ensure that changing the selection changes the data source repeating table, as shown in Figure 3.

Figure 3. Changing the selection field changes the data source repeating table.


So now the challenge is to place those entries of the dependent data source into the repeating table of the form.