Brad wrote:
Hello,
I have implemented your autonumbering for infopath form solution. Works great except the first document they submit returns a NaN from the ID. Anyway around this?
Thanks,
Brad
Hi Brad,
Thanks for alerting me to this ‘bug’. I’ve updated the article to include this caveat. The max() function is failing because there aren’t any IDs to evaluate. The way to solve this issue is by using a conditional statement, so that the max() function is only used when there are IDs to evaluate.
To implement this solution, the form template would have to be constructed differently. This is a topic for another article, I’m afraid. So when I have time again I’ll write another one. Since it might take a few months before I get around to writing articles again, you can have a go at constructing the solution yourself. You would have to do the following:
- Change the RetrieveIDs data connection to use the autonumber field instead of max(@ID) + 1.
- Add a Button to the form with the following 4 rules:
- Disable the submitting of the form via the Submit button on the toolbar (the Button you added will submit the form instead)
- Query the RetrieveIDs data connection
- Set the autonumber field equal to 1 when count(@ID) = 0
- Set the autonumber field equal to max(@ID) + 1 when count(@ID) > 0
- Submit the form to the form library
Hope this helps. If you have any questions, let me know. While I’m extremely short on time these days, I will still be able to give you short and quick pointers to get you ahead should you get stuck.

Comments to this post were closed 30 days after it was published.