Forum Documentation Showcase Pricing Learn more

Ensuring Unique Generated Numbers


#1

Hi,

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?


#2

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


#3

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.


#4

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


#5

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.