# Ensuring Unique Generated Numbers

**URL:** <https://forum.bubble.io/t/ensuring-unique-generated-numbers/46249>\
**Category:** Questions\
**Created:** [January 9, 2019, 1:05am UTC](https://forum.bubble.io/t/ensuring-unique-generated-numbers/46249 "2019-01-09T01:05:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcuslate](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@marcuslate](https://forum.bubble.io/u/marcuslate)\
**Post date:** [January 9, 2019, 1:05am UTC](https://forum.bubble.io/t/ensuring-unique-generated-numbers/46249/1 "2019-01-09T01:05:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JohnMark](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/johnmark/32/42431_2.png) [@JohnMark](https://forum.bubble.io/u/JohnMark)\
**Post date:** [January 9, 2019, 1:25am UTC](https://forum.bubble.io/t/ensuring-unique-generated-numbers/46249/2 "2019-01-09T01:25:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [January 9, 2019, 7:07am UTC](https://forum.bubble.io/t/ensuring-unique-generated-numbers/46249/3 "2019-01-09T07:07:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![marcuslate](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@marcuslate](https://forum.bubble.io/u/marcuslate)\
**Post date:** [January 9, 2019, 12:22pm UTC](https://forum.bubble.io/t/ensuring-unique-generated-numbers/46249/4 "2019-01-09T12:22:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marcuslate](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@marcuslate](https://forum.bubble.io/u/marcuslate)\
**Post date:** [January 9, 2019, 12:24pm UTC](https://forum.bubble.io/t/ensuring-unique-generated-numbers/46249/5 "2019-01-09T12:24:43Z")

</div>

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.
