If somebody like the post and its helpful in your work then, add comments.

Sunday, November 30, 2008

Auto Number in the Repeting table of InfoPath 2007

If you want to display a row number on a repeating table you can use an Expression Box with the XPath set to position(). This is great if all you want to do is show the row number. But if you actually want to store the sequential autonumber in a field, there's a different XPath you can use.

We will assume that you have the following structure representing your table row:

my:Row
my:Number
my:FieldX
my:FieldY
my:FieldZ

We will also assume that you want my:Number to be automatically populated with the row number, while staying continually updated as rows are inserted and removed.

Double-click the Number field in the repeating table.
On the Data tab of the Text Box Properties dialog box, ensure that the Update This Value When The Result Of The Formula Is Recalculated check box is selected.
Click the Insert Formula button to the right of the Default Value text box.
In the Insert Formula dialog box, type the following formula:

count(../preceding-sibling::my:Row) + 1



Click OK twice.
Now preview your form and try it out. Whether you insert or remove rows, each Number field has the correct row number stored in it.

1 comment:

  1. Resourceful post.
    SharePoint consulting can provide a business with custom web parts and administrative tools. This helps an organization with development projects.
    vellian

    ReplyDelete