Random Jump With Autonumber

0
I am seeing some strange behavior with Auto Number of an Entity. The numbers is skipping values, it has jumped from 1891 to 1924. Is this normal behavior?  
asked
2 answers
2

Hi Martin,

Yes this is correct. Autonumber will always increment +1 on create of an object, even if it is not committed after that.

In your case this means a lot of objects were created, but not saved to the database.

answered
0

Hi Martin,

What Sjors and Mike are saying is that because of the nature of the AutoNumber attribute type (it's guaranteed to be unique), the value of the attribute is distributed by the database, and this happens at the creation of the object, and not at the commit. This means that every time a user creates an object, but doesn't save the object, a new number was given out. If it is not saved, the number is ‘lost’. As Mike mentioned, if you want to keep sequential numbers, you need to create your own logic.

What I can guarantee however, is that there are no gaps or skips in AutoNumbered values that are put on objects. Somewhere in your application, those intermediate objects have been made, and have not been committed.

Perhaps you can find them by using a temporary After-Create event handler and log the moments when objects are being created.

Good luck.

Greetings Martin

answered