Yeah there’s exactly 1 million unique 6 digit numeric strings:
000000
000001
…
999998
999999
And I suspect that @cobi doesn’t really mean to convert these to numbers. They should be strings (“texts”). You’ll note that if your generated ID has leading zeros those will disappear of course when converted to an actual number, so unless you catch that some of your IDs will have fewer than 6 digits.
AND, here’s a way to do the same thing @mikeloc did, but in the page…
There’s no “real” reason you couldn’t do this kind of recursion in the page using Custom Events (assuming that the privacy rules allow the page to see all Classes and their Class Code field), except that Bubble prohibits custom events from directly or indirectly calling themselves.
Of course, you won’t be surprised we could work around that with List Shifter if we wanted to do it in the page. The basic technique is to use List Shifter’s Custom Value (which is like a custom state, but also can fire an event when it’s updated) to hold the generated “class code”.
Here’s how to set up List Shifter (I used number in my example, but as I said these should probably be strings):
And then also set List Shifter’s Process Output Type (which also controls the type of the Custom Value) to number as well, lower down in the main property inspector:
Create a Custom Event that represents the Class Code generation:

And then the workflow for this event simply:

And now set up 2 workflows - 1 to handle the case where the Class Code did not collide, and one to handle the case where the generated Class Code already exists:
Here’s the collision case:
And the workflow is just trigger Generate Classcode again:
Here’s the non-collision case:
And the workflow for that case is just now create (or in practice, perhaps modify) our Class using our Class Code:
And there ya go - in-page recursive workflows with List Shifter.
Live example with editor viewable (click button) here: https://list-shifter-dev-test.bubbleapps.io/version-test/classcode?debug_mode=true
That page is currently set to generate 3-digit codes so you can sometimes generate a collision. When that happens, you’ll note that Debug Buddy logs a message to the console. Of course, eventually there is a risk of infinite recursion once all Class Codes are used up. One would probably want to use a second List Shifter or Custom State to increment a number so that you put a max number of regenerations and break out of the recursion if the namespace fills up…