You'll have to add a data connection to the library the form submits to. You can then, in rules, as part of the submit rules, query the library to get a count of items. Then you can use a concat formula to prepend leading zeros to the count - sample formula can be found in this thread: https://www.infopathdev.com/forums/t/20643.aspx. Keep in mind that this is not 100% guaranteed to get you unique numbers - it might be possible for two users to be submitting at the same time, and for the count to be the same.
Hilary Stoupa
