Chalk this one up to user conditioning, i.e. being too accustomed to Infopath-based frustration with things that aren’t possible. In spite of myself, I stumbled upon a handy capability that, had I bothered to read the dialog message completely long ago, I would have known earlier.
I am working on a form that will use several sections containing repeating tables, all of which will have an identical structure and be populated at runtime from a secondary data source using code-behind. The sectioning is based on the specific year to which an entry belongs, for example, Year 0, Year 1, Year 2, etc.
Because the data is identical for each row, it would be nice to be able to create the structure once, and copy and paste it to the other sections, but of course copy and paste is not an option in this case. Furthermore, if one tries to manually reproduce the same structure, they are presented this error dialog:
In the past, I have encountered this message, but it was not insurmountable and actually made sense for me to use slightly different names for similar (but not identical) groups. But for today’s efforts, that was not the case. So, as it turns out, ACTUALLY READING AND FOLLOWING THE INSTRUCTIONS yielded fantastic benefits with no pain or mind-numbing repetition.
I want to “copy” the CLIN repeating group into the OptionYear5 group as shown below:
To do this, all I need to do, instead of creating a new repeating group and fields by hand (called CLIN5 or something to avoid the error message above), I simply right-click CLIN and select Reference, then pick OptionYear5.
With just a couple of clicks, the desired result is obtained:
Not only was I able to avoid a huge amount of drudgery, but the form is much more maintainable, because I can edit the “base” instance, and all of the linked references will be updated. It will also simplify the underlying code-behind, since I won’t have to account for some naming convention that relies on a number appended to the group or field names to make them unique.
Speaking for myself, it’s amazing what we can learn by actually reading dialog messages instead of angrily clicking them away, assuming the worst.
Filed under: Form Design, InfoPath, Troubleshooting, XPath and Rules Tagged: Groups, Re-use, Reference, Repeating
