Database Number Range

Part of my app will be locker registration. Our facility has something like 600 lockers for employees to use for their work equipment. Is there a way to put a number range into the database without having to manually input each number? For example, 1R000 - 1R125

I found this post in the Bubble forum, but I can’t say I really follow Keith’s explanation.

It’s not entirely clear to me what you’re asking here…

I assume you’re asking how to set a number range via a workflow? (although in your example, of 1R000 - 1R125, those aren’t numbers but texts…)

But do you mean setting the number range to some user input value? Or a predefined value?

OK, so here is my locker data type. I understand that 1R000 is text and not a number, but the section prefix is attached to each number in our facility.

To get all the lockers in the building facility listed in the database, I would have to manually add each entry like I have here by doing the whole new entry button, fill out the form, submit, rinse and repeat.

My question is there a way to get around having to do it this way? It would be great to be able to create something that allows me to say, “Add entries in the Locker data type for lockers 1R000 - 1R125.” Basically I set the beginning value and the end value, and it just submits the entire string to the database.

Ah ok I see… (I thought you were asking about the ‘Number Range’ field type…)

But (i think) you’re asking about how to create a defined number of database entries for a particular datatype…

In which case the simplest way will be to run a recursive workflow to create the database entries.

There are plenty of forum posts about running recursive workflows, so I won’t go into details here…

But all you need to do is set up a backend workflow to create a new ‘locker’ entry, pass into it the locker number, and the total number of entries you need to create (i.e. for the first run the locker number might be 1, and the total number of lockers might be 125)

Then just schedule itself to run again, pass the locker number as the current locker number plus 1, pass the same total number of lockers (125), and have a conditional set so it will stop running once the defined number of entries have been created (i.e. only reschedule the workflow when the current run’s locker number is less than the total number of lockers).

note: you’ll need to use actual numbers for this (not texts) so you’ll need an additional field for the actual locker number as well as the text field you’ve currently got.

1 Like

Thank you! I will delve into the recursive workflow posts on here and see what I can find. I’m new to Bubble, so I’m trying to get my hands on any and all learning material that I can. It’s just getting the right verbiage down to find what I’m trying to do. So thank you for providing that direction!

1 Like