This has always been a question from many developers. How to retrieve the Next [Document] Number programmatically and how to increment it?
GP does the following whenever a Document Number is retrieved from Next [Document] Number setup and eventually create/leave that document:
1. Retrieve the Next [Document] Number from the respective module setup table.
2. Increment the Next [Document] Number on that table, immediately after it populates the number on the respective form.
3. While saving the document/posting, it does not do anything to the Next [Document] Number on the setup table. It’s just a document posting process.
4. While deleting the record, it decrements the Next [Document] Number, if and only if, no other user has created another document using the immediate Next [Document] Number, or even opened the respective Document Entry form to create one. If there is any other User Activity on this, GP does not do any kind of decrement.
Having said that, the consequent queries from all developers/consultants would be:
1. What will happen to the stranded [Document] Numbers?
2. Can we reuse it?
3. Can we instruct GP to reuse it?
To my knowledge, the answers are:
1. Stranded [Document] Numbers are left stranded, as far as GP is concerned.
2. YES, we can reuse it, but the Users should know which number, to their best knowledge, is stranded. The numbers can be reused, once we setup an option, kind of “Override Document Number” or something like that.
3. We currently do not have some kind of setup which will manage the Stranded Numbers and automatically instruct GP to reuse them. It would be great to know any such 3rd party product in the market, but at least, GP does not have it as an in-built functionality.
I believe, I have been correct on the above explanations to the best of my knowledge. In case, there is anything that is not correct, something to add to or something which I am still not aware of, please do update me.
Vaidy