InfoPath – Limit the number of items in repeating table
Posted
Wednesday, April 14, 2010 12:07 AM
by
Itay Shakury
Credit for this cool trick goes to Ziv Cohen (from BSP)who found and showed it to me.
If you want to limit the number of items in a repeating table, there no apparent way in the UI to do it. Here’s a quick way to do it without writing code.
- On a form with a repeating table. Pay attention to the Group that the Repeating table is bound to.
- Get the source files of the form. (in 2007: File –> Save as source files. in 2010: File->Publish->Export Source Files)
- Close InfoPath.
- Open the schema file. It’s the file with XSD extension.
- Find the part representing the Group of the Repeating table (from step 1), and it’s sequence in it’s parent group.
- The group should have an attribute called “maxOccurs”
- This is what we’re looking for, set your limit here. (any number)
- Open the modified form in InfoPath (the easiest way is right click on manifest.xsf and click “Design”)
- Continue your editing… When you’re done just save the file as normal XSN, and you can dump the source files.
When you fill out the form, you won’t be able to fill more items then what you’ve specified in the schema file
This should work for browser forms too.