Ensuring Unique Generated Numbers


When my users sign up, I automatically generate a string of 8 numbers as their username. This is using Bubble’s built-in “Calculate RandomString” function.

I’m pretty sure this does not actually ensure that each number is unique(?). So how do I ensure that the generated number is unique?

Compare all your data users unique 8 numbers with the new ‘randomstring’. If exist, do it again (in a loop).

1 Like

It will be unique in the vast majority of cases. But you can code round this by checking the generated string at signup time and pushing some innocuous message like “oops please try again” if it isn’t.

Yes and how do I do this in workflows? I can’t seem to find what functions I need.

At signup the username is generated, then I will allow them to change it later. But not sure how to check that the username is unique in workflows.