Autonumber repeating table rows in InfoPath 2010

Learn how you can use a formula in InfoPath to autonumber a repeating table by automatically assigning sequential numbers to rows of the repeating table on an InfoPath 2010 form. This solution also works for InfoPath browser forms in SharePoint.

ADVERTISEMENTS

In a previous article I wrote about how you can in InfoPath autonumber repeating table rows using VB.NET.

A best practice to keep in mind when designing InfoPath form templates is that you should always use code as a last resort, and instead give preference to solutions that make use of rules and formulas.

Code not only requires you to have programming skills or forces you to outsource your InfoPath form templates design to someone who has these skills, but it typically also involves more steps in particular when deploying InfoPath form templates to SharePoint.

So in this blog post, I’ll show you a way to use a formula to in InfoPath autonumber repeating table rows, so that you automatically get sequential numbers in a repeating table field whenever rows are inserted or deleted. By the way, this solution also works for InfoPath forms that are hosted in SharePoint and filled out through a browser.

This is what the final InfoPath autonumber repeating table form would look like in SharePoint:

Autonumber repeating table rows in InfoPath 2010

Figure 1. Autonumber repeating table rows in InfoPath 2010.

You can in InfoPath autonumber repeating table rows as follows:

  1. In InfoPath Designer 2010, create a new Blank Form template.
  2. On the Home tab under the Controls group, click Repeating Table and add a repeating table with 3 columns to the form template.
  3. Right-click the first field (field1) in the repeating table and choose Change Control and then Calculated Value from the context menu that appears.
  4. With the first field (field1) still selected, click the Properties tab or double-click field1 to bring forward the Properties tab.
  5. On the Properties tab under the Properties group, click Default Value.
  6. On the Field or Group Properties dialog box on the Data tab under the Default Value section, click the formula button behind the Value text box.
  7. On the Insert Formula dialog box, select the Edit XPath (advanced) check box.
  8. On the Insert Formula dialog box, type the follow formula into the Formula text box:

    count(../preceding-sibling::*) + 1

  9. On the Insert Formula dialog box, click Verify Formula to ensure that the formula does not contain any errors. Click OK to close the message box that says whether the formula contains or does not contain errors. Correct any errors if necessary.
  10. On the Insert Formula dialog box, click OK.
  11. On the Field or Group Properties dialog box, ensure that the Refresh value when formula is recalculated check box is selected, and then click OK.
  12. Save the InfoPath form template and publish it for example to a SharePoint form library.

Now whenever you insert or remove a row from the repeating table, the numbers in the first column of the repeating table are automatically recalculated and displayed sequentially in ascending order thereby creating an autonumbered repeating table in InfoPath.

 
 Subscribe via RSS or Email

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners
InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013
InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners
InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010
InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers
InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services


Related Posts

ADVERTISEMENTS

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services