Auto-number should be rolled back when canceled an operation

Hi ,  I have provided autonumber for an attribute in a page.But when you fill the information in the form but cancel it instead of saving the autonumber attribute should be rolled back.It should not iterate on cancel operation kindly Let me know if you have any workaround
1 answers

You can do some dirty stuff with autonumbers on database level, but the easiest workaround might be not to create the object.

You could create a non-persistable helper object on which you collect all the information and copy everything to your persistant object when the user saves it. Doing so, you don’t even create the autonumber in case the user hits cancel.