InfoPath

InfoPath – Limit a Repeating Section

I had a requirement in one of my forms to limit the number of repeating sections to be displayed.

I read through some blogs that gave me some ideas on how to increment the row number which was very helpful and got me on the right track. Check them out when you have a moment:

http://nickhurstblog.com/2011/08/26/infopath-2010-repeating-table-incremental-row-number/

https://alecpojidaev.wordpress.com/2010/01/07/accessing-previous-rows-in-repeating-group-for-browser-enabled-forms/

Basically, you will need to auto increment a number field when a new section is added to the form. There is a very simple way to handle this and it only takes one rule and one field.  To do this, follow these steps.

  1. Create a new interger field and add to your repeating group.  For this example, we will name it Count
  2. Right click on Count and click properties, then click the fx button.
  3. Check the box to Edit XPath (advanced) and enter in the following formula: count(../preceding-sibling::*) + 1
  4. Click Verify Formula then click OK
  5. Make sure ‘Refresh value when formula is recalculated’ is checked
  6. Click OK
  7. If you have not added the repeating section to your form, do this now
  8. Preview your form to make sure that everything is working properly
  9. Click on the repeating section and then click ‘Manage Rules’ in the ribbon
  10. Add the following formatting rule
    1. For the Condition:
      1. Field: Count
      2. is greater than or equal to 5
    2. Check ‘Don’t allow users to insert or delete this control’
  11. Preview your form

You should now see that you can only be able to add a total of five repeating sections.  You can change this number to limit what you actually need.

I have included an example template that demonstrates how this works.  Please note that this form was created in InfoPath 2013 and is a browser based form.

LimitRepeatingSection

Enjoy and Stay Salty!

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.