Does anyone know a reliable workflow to generate a unique 6 digit number string? I already tried calculate random string on my 4000 rows and lots of them had duplicate values. I needed this for the account code that will be tagged with the members name in the database. Please help me out, Im so stucked on this.
This is what you can do. And what I use to generate a string for a 2-step verification system:
Does that answer your question?
Thank you Nathan, but this never seems to solve my problem. This is what I actually did in the workflow in every valid registration except for the “Only when” condition which I dont think will help in preventing strings to duplicate in over 4000 rows and counting…
Could you send me a picture of your workflows?
Hmmmmm… Seems really confusing and harder than I thought.
Yeah, this data is from a registration form. Rest of the data inputs are okay. Only this 6 digit string that I need to be NOT DUPLICATING no matter how many new registrations are being pushed into the DB.
What do you mean by duplicating? Like whats happening when it duplicates?
unless ofcourse if all the possible 6 digit combination is used up.
Member 1 = 000001
Member 2 = 000001
instances like that should not happen. bcoz each member must have a unique 6digit code for itself
Did you know when each user signs up they get their own unique id already generated by bubble?
yes but that’s a long string. Is it possible to trim that into 6 digits without having the possibility of duplicating?
I dont think so with your situation. Plus with whatever your creating there could be a lot of users and then you would run out. Trust bubble on this one.
This is a question that comes up quite regularly on the forum (there are quite a few answers too)…
There are a few ways to go about it depending on your setup, but basically, in order to check the uniqueness of a calculated string you’ll need to set up a ‘loop’, or a recursive workflow, to check if the generated number is unique, and then generate a new one if it’s not.
In native Bubble you can’t to this in the browser, so it has to be done on the backend, but it’s fairly simple to do.
Simply create a backend workflow with 2 actions, 1 that will generate and set a new random number for the ‘thing’ in question, and another that will schedule itself to run again.
Have an ‘only when conditional’ on the entire workflow so that it will only run when the random number IS a duplicate (i.e. its count > 1) (you’ll need to run a DB search to establish this).
Then in your browser workflow, generate the initial random string, then schedule the backend workflow to run right away.
The backend workflow will check to see if it’s a duplicate and, if it is, it will generate a new random string. It will continue to check that it is not a duplicate until a unique random string has been generated, then will stop running.
there could be a few thousands but not a over a million I believe as this app is created specifically for an organization which membership is limited within a specified area. Pretty sure all possible members will be able to register without using up all the possible 6 digit number combinations. I just need them to NOT DUPLICATING. Each new registration should generate a string that does not exist yet in the DB
I’d hate to say it but I dont know how to help you. I dont think others have an issue with it being long. I personally dont think that it’s too long. Hopefully you figure it out or take my advice to trust bubble.
Best of luck,
He is trying to make is own and make it 6 digits. But it wont make a new one for each user.
If you would like you can signup early for Noqode. We will do lessons and tutorials to help people on their No-code journey!
https://breeze-donations.bubbleapps.io (Have not set up custom domain yet)
Yes, the shortest way to say it. sorry I took the long way.
Sounds like you’ll need a recursive workflow that works like this
Trigger custom workflow
Modify current users randID
-IF a search for User’s randID does not contain randomstring from step 1
Trigger custom work
-IF a search for User’s randID does contain randomstring from step 1
Have you set one up before?
This workflow would call itself u til the conditional on step 2 is satisfied.