Generating a sequence string

Hello,

I want to generate a 4 digit code for a ID Number and i want it to be in sequence.

I am currently using “Generate Random String” in the workflow to generate them.

Is there a way i could generate them in sequence? so when users signup, the ID Number gets generated in a sequence number.

And i want to have that certain users who are for example set to “Volunteer” start for a specific digit.

For example:

0001 until 0100 are specifically reserved for Management.

0101 until 9999 are for Volunteers.

Is there a way i could do “when current user’s position is Volunteer → generate the next sequence number”?

Thank You

Do a search for Users where Created Date < Current date/time:count + 1

(some variant on that)

You will likely want to do that in a backend custom event that bypasses privacy rules to return this count, else you’d be exposing the user data

I tried doing it, but can’t figure out how to set it up.

could you explain how I could do it in the workflow or backend workflow.

What have you tried so far?

I tried creating a backend workflow. but I never used backend workflows so it’s my first time. so I need some instructions on how to do it.

You should share some screenshots of what you’ve tried so far :slight_smile:

didnt really try that much. just put it as custom event but didnt understand anything, so need some instructions from the beginning.

Ok, have you tried the manual or academy then for Bubble basics? It’s a bit difficult to know where to start otherwise.

not for the backend workflows, no.

I kind of sort of started with something like this for a referral program on my app.

I ended up scrapping it and went to something else instead…

so, this is not necessarily a complete way to do what you want, but it may get you thinking in the right direction.

I think you should have a separate data type for counter, and then create one manual entry for user or whatever, and one entry for manager, and also assign them a number… like 0000 or whatever you want. You could have an option set that has user and manager.

Then, when a user signs up, you make changes to a thing… which is counter, and do a search for the first item that matches the user type and +1 to the number.

Then, you make changes to the user and use the number from step whatever. You would, of course, need to format the number.

In my opinion, this would be the simplest way to do it. I really don’t think every time a new user signs up, you want to do a whole search through all your users for the next sequential number?

Anyway, this is something you can think about and consider