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?
Sincerely,
Nathan
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,
Nathan
He is trying to make is own and make it 6 digits. But it wont make a new one for each user.
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
Create user
Trigger custom workflow
Custom workflow
Create randomstring
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.
Im giving this a try. I have a feeling this will get me what I want. Thankyou very much to all of you.