Looping through every day of a year in BEWFs

Hi there!
I’m using an API Backend workflow to generate one element for every day of a year. So from the front end, I’m triggering a BEWF that triggers another recursive one with a ‘date’ as parameter and I set the next date by using thedate+days:1.
But… For some reason, I’m missing entire days, but can’t seem to find a pattern…
Do you have any idea what is going on? Or recommandations on how to do it better?
Thanks !

Do you really need to do some recursive process on the backend for each day of a given year? Or are you just looking to generate a list of days in some given year in the page (client side)?

Either way, don’t generate that list of dates via a recursive backend workflow. It’s insanely costly and slow.

Use a plugin that can do this, preferably on the client side, not as a server-side action, unless that’s really what you need. (There are both commercial and free plugins to do this, with varying levels of quality and weight.) For client side splitting of some date range into individual dates representing days, you could use my Parallels plugin, which uses the lightweight Luxon library (and implements almost all features of that library). But there are other date manipulation plugins.

I’d avoid plugins that rely on the moment library for this as it’s deprecated and overly large via-a-vis modern libraries.

Perhaps others will chime in with their favorites.


Thanks @keith
I do need to create an object because I need to store different data for each day.

No you don’t. Your data object (whatever it is), needs a date attached to it. Different thing, you see?

@keith Yeah, sure. But I still need one object for each day of the year. It seems a bit heavy for front-end action no ?

How about a recurring backend workflow that is set to recurring Daily?

Thanks @boston85719 But I need it to happen retro-actively, for the past year.

As has been discussed using some plugins to generate the list of dates, you can use one that I like, which is free, called 1T List of dates. Very simple to use and creates a list of dates on the frontend that can be used as values of a backend workflow parameter.

I’d say use that plugin to generate your list of dates for the year, setup the backend workflow to have a parameter which is a list of dates, which will come from the plugin element list of dates when you schedule the backend workflow from a page.

The backend workflow can be recursive as you know, and I’d use the recursive portion of the backend workflow (when it schedules itself) to populate the list of dates parameter with dates list minus item dates list first itemand in the actions for setting the date on the database things I’d use the value of dates list first item.

For the condition on when to stop the looping, I’d use the expression dates list count > 1

BTW, dates list is what I would name the parameter for the list of dates.

And yes, this will work at a slower pace than what would be optimal for a real time use, but sounds like you want it to just populate some necessary data and users will not be interacting with it.

If, however, you want users to interact with it, you can still use the 1T list of dates plugin (super fast), but may want to look into using an API call to your app to bulk create things rather than rely on the recursive backend workflow which to create the 365 things may take a minute or two.


@tart2000design if you need to do what you say you do, then I wouldn’t use a recursive workflow… (it’s by far the slowest and most WU costly way to do it in Bubble).

The fastest, and cheapest way is to use the Data API Bulk Create endpoint, but alternatively, just run an API workflow on a list (it’s a lot faster and less costly in WU than using a recursive workflow).

I just ran 3 simple tests to generate a list of 365 items in the database, one for each date of the year:

Recursive Workflow (with no delay between runs):
2 Minutes 40 Seconds
851 WU

API Workflow on a List:
17 Seconds
632 WU

Bulk Create Endpoint:
6 Seconds
183 WU

So, whichever way you look at it, there’s really no comparison (although 6 seconds to create 365 things in a database is still slow, if you ask me).


Hey, thanks a lot @adamhholmes.
Can you describe the API WF on a list method please ?
What expression do you use to split a year by date ?

You still need to create a list of dates (or even just a list of numbers), which you can do with some simple JavaScript or various existing plugins (there are even ways to do that in vanilla Bubble, with no plugins, but they’re a bit ‘hacky’).

Then just run the API workflow on that list.

(if using a list of numbers, just pass the same start date into the API workflow, and add the number Days as per the number in each run of the workflow).

That is also my suggestion… to create a large list of thing in Bubble, I don’t know a better way…

1 Like