Creating Unique Random Strings For Each User

Hello,

I am trying to create a unique 4 digit number for each user that signs up for an account. I have used Calculate Random String to create a four-digit code when the user signs up. However, I am not sure how to make sure that the code created is not already in the list of all the Code data. How should I approach this problem?

Thank you!

Use the condition “Only when”, Code not in List of codes existed

Hi @edward

This may work for you.

Instead of putting that ‘Calculate RandomString:converted to number’ straight into your Code field, as seen in your image above. Put the calculated 4 digit code into a custom state before hand. Once you have that, you can then do a search for the custom state value and only use it if it’s not already found.

Like this…

Only problem is that if the chances of a randomly generated 4 digit code has been generated and used before, then you’ll have to handle that.

In the formatted text part, value for Yes is just Index code, value for No I left blank. It might be good enough for what you need or there might be a better solution to handle this but hopefully this may get you thinking into other ways to tackle it. :slight_smile:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.