I'm operating within the context of a before insert operation, but I'd like to display the current auto number on the creation page. Without the record being inserted into the database it isn't possible to display the number.
I thought of doing something like this in apex (pseudo-code):
Integer LastNumber = [SELECT Name FROM Object ORDER BY CreatedDate] // Get the last record
LastNumber = stripAutoNumberPrefix(LastNumber); // Strip the prefix
return LastNumber + 1; // Increment one to the number and you have the new auto number.
to get the next autonumber in sequence, as there's no system methods I can use.
Is this a good idea? Is the order of auto-numbers explicitly guaranteed?