Infopath 2010 : Display one item at a time from a repeating group

Suppose you have a repeating group and you want to display only one item from the group at a time. Moreover, you want to be able to add a new item displaying only this one.

For this you need to know the currently displayed item and be able to identify uniquely each item.

Create the data source like this. With in particular a “CurrentItemID” to know the ID of the item to display and a reapeting group with a unique identifier “ItemID”.

Set the “CurrentItemID” default value to 1 to display for the first element on load.

The default value of the “ItemID” field must be an incrementale number. Therefore calculate the value from the previous field + 1. For this use the function button and insert the following formula: “count(../preceding-sibling::my:RepeatingGroup) + 1”.

Next add a rule on the repeating group which will be triggered when a new item will be inserted. This rule set the current item id to the value of the new item id.

For this select the repeating group in the field section and choose “Home”/”Manage Rules”¬†on the and add a new action rule :

Next construct your form like this:

The repeating group is inserted two times : The first to list the item available and the second to display the current item properties.

On the first occurrence, I set the default value of the button to the current item id following by the current item name.

You must add a new action rule on the button. This will change the current item ID to the selected item id.

On the second occurrence, you must add a formatting rule to only display the current item properties.

Launch the preview. The list of the available items is on the left and the current item is on the right.

When you choose an item by click on the left, the properties of the item appears.

When you choose to “Insert item”, on the right a new item appears and you can complete the properties.