Also, why should we transform to text? Doesn’t Bubble handle numbers correctly?
“00001” is not a number (at least not in the mathematical/quantitative sense, which is how Bubble, and other programming languages, define a number).
The number here is simply “1” - whether you stick 4 zeros in front of it, or a million zeros, the number is still just 1, so if you use a Number type in your Bubble datatype that’s how it will be stored (as you’d expect, and as it should be). Just 1.
So if you want to store “00001” it therefore has to be a text, which just happens to contain numerical digits.
So, as other users have stated above, you first need to calculate the new number for your invoice (either do a count of existing ones and add 1, or find the most recent one, convert it to a number, then add 1).
(Potential duplication issues due to race conditions aside), that will give you the actual ‘Number’ for the invoice (i.e. if there were 247 previous invoices, the new one will be numbered 248).
But if you want to store that as 00248 then you’ll need to add the preceding zeros (as text) and convert the number to a text, then save it in the ‘text’ field of your database (you could save it as both a text AND a number to avoiding having to convert it to a number in future, for example when sorting or searching for it).
You’ll need to use conditional actions in a workflow, based on the number of digits in the actual Number, to determine how many preceding zeros to add to the ‘text’ invoice number field.