Using MAX() function to populate "incrementing" field

T

Tom G

I have a repeating table. The first field is an ID field that I want to
auto-populate with an incrementing integer. The field is read-only.

I tried setting the default value for the field to be "max(.)+1" but that
generates a NaN when I create a new form.

I then tried "max(nz(.))+1", to treat blanks as zeroes (my form option is
already set to do that but it doesn't seem to be working). This avoided the
error, but the rows are all numbered "1".

I then tried creating a rule in addition to) a default value of "1". The
first two rows were correctly numbered "1" and "2" but every subsequent row
was also numbered "2", suggesting that MAX() is not working as I would
expect.

Is there a better was to do a incrementing field in a repeating table? Or
can someone spot the error in my approach? Or is this a known bug in
InfoPath? Thanks.
 
J

Josh Bertsch [MSFT]

MAX will return the largest number in a given node-set.

Try using:

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

--josh bertsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top