Forum Academy Marketplace Showcase Pricing Features

[New Feature] Recurring workflows

@emmanuel I am not 100% sure if I understood, I have been doing manually for the last couple of years, a manual workflow every first of January at the first couple of hours, in order to update the years of the users and know how old they are based on they birth date, I have created a button with a specific Workflow in a page I only open that day for that purpose only.
How can I make this workflow recurring every year on that day, do I need to activated somehow? How can I be sure it is working?

Just an aside here, but you say you do…

Why would you ever need to do this? You say your User objects have a “date of birth” field on them.

So… You always know how old your Users are.

(Users age = Current Date/Time - User’s date of birth [format as whatever you want: years, seconds, whatever].) I can’t fathom the use case for maintaining an “Age” field on your Users.

Similarly, you always know how long your Users have been Users. (Tenure on system = Current Date/Time - User’s Created Date [again, format in whatever time increments you want].)

This is really cool. Could this be used to run a check (via API) every X hours (if it schedules itself X hours in the future every time it’s run)? Thanks!

I would need to check it out. But I am pretty sure what I would get here it is another date. And that is not what I need. What I really need is a number telling me how old the user is and if today is his birthday, I would need to know how old is he today.

Nope: Current date/time - some other date:format as some-time-unit is a number, not a date. This can be seen in the expression below.

The second expression there, by the way, is one way to get a Boolean representation of “today is the user’s birthday”.


@caeroa - following @keith’s points, we shared a few ways of thinking about this on a related post a few days back.

1 Like

@dan1 and @keith Thank you so much, I did this around 2.5 years ago , I remember it was a little painful to get a perfect years of an user, I will give it a try and I will let you know. take a look of this, the way I solved it:

btw, @dan1 , @keith , do you guys know something about this?

If you’re trying to get round numbers (ie. you’ve taken Current Date - User’s Birthdate), the function returns the number of milliseconds between those dates, which you can convert into days/months/years using math.

If the issues is getting “perfect” years, you can use the :floor function, which will round down. (Ie. 40.59 years becomes 40.0). Video explaining the setup below.

Hi Keith,

Wouldn’t a usecase be if you want to use the age in a chart? ( For instance purchases per age of customer)? Seems tricky to do a calculation like you mentioned for every customer in your database at the moment of producing the chart.

My recommendation would be to apply “buckets” to users for an age range. (Ie. 18-24, 25-36, etc). If necessary, you can do a recalibration as needed with a recurring workflow.

Then you can do a simple group by function versus trying to extract individual birthdates and normalize into buckets. It’s not the same level of precision, but gets you more or less the same result if the granularity isn’t necessary.

Hey @keith and @dan1, thank you for showing me those expressions, but there is a flaw in the expressions, there are not 100% accurate, it could show me the age of a user if the birth date is 10 or more days away in the future, I did try everything with expressions with no 100% results, I am going to show you how I did it more than 2 years ago and is working perfect, (btw, my question about recurring workflows it wasn’t related to the age of an user it was related to how to show the birth date in the calendar bubble has embed it, my bad, I will keep looking how to do it) but first take a look:


this is my real birth date showing my age:

Here you can see my real Birth date, which is a couple of months away, it is showing the correct age in both cases.

Now lets try to hard code my birth date to a day like today in 1976 in the app data for users:

It works perfect in both cases, today it would be my 42 birthday, I would be 42 years old.

The problem begins here, lets say my birthday is tomorrow in 1976:

My way it is showing it correctly, today I am still 41 and tomorrow I will be 42, your way on the other way it is not correct, is showing 42 y/o.

Lets change the date for 10 days from now 10/07/1976:

Still we have the same problem.

Now if we change it for 11 days from now 10/08/2018:

Both cases are showing the correct age.

that is why I say your way it is not 100% perfect, I can’t have that gap of 10 days in my app, i need to check the age of my users every single day, and because we have birthdays every day this has to be perfect.

I tried every single way of writing expressions to show the correct age with no luck, I got stuck for a couple of months until I found a solution I am showing here:

First I created this event when the page is loaded:

I change some fileds (index) in every user for year of birth , month of birth and day of birth:

For the year I subtract from the current year the year of the birth of the user, in my example: 2018-1976 = 42

For the month I subtract from the current month of the year the month of the birth of the user and divide by 12, in my example: (09-12)/12 = -0.25

For the day I subtract from the current day of the year the day of the birth of the user and divide by 365.25, in my example: (27-23)/365.25 = 0.0109514031485284

Then in a following event also when loading the page I add all this numbers to another field from the same user:

So this field is: 42+(-0.25)+0.0109514031485284 = 41.76095140314853

Then I show this filed as the age and floorit!

And always get a correct age.

Lets repeat the exercise with the dates showed before for today, lets say I was born 09/27/1976:
2018-1976 = 42
(09-09)/12 = 0
(27-27)/365.25 = 0
42+0+0 = 42
Total 42 ! Correct Today would be my 42 birthday today ma age would be 42 (42 floor is 42)

Lets say yesterday was my birth day, 09/26/1976
2018-1976 = 42
(09-09)/12 = 0
(27-26)/365.25 = 0.0027378507871321
42+0+0.0027378507871321 = 42.0027378507871321
If we floor 42.0027378507871321 the answer is correct I would got 42 yesterday.

Now, lets say my birthday is tomorrow, 09/28/1976:
2018-1976 = 42
(09-09)/12 = 0
(27-28)/365.25 = -0.0027378507871321
42+0+(-0.0027378507871321) = 41.99726214921287
If we floor 41.99726214921287 the answer is 41, !!! Today I am still 41 so this works flawlessly!!!

I am not going to lie guys, I was so happy when I did this, when I finally found the way of displaying the correct age of an user every single time. Again, I did more than 2 years ago, and even trying to remember all this to explain it to you, brought me joy :slight_smile: . There could be another million options, but this is the one I made up and works 100%, works for me!

I hope all this make sense, I know I had to use the workflow and events and fields from the user instead of a simple expression, but this works!!! :slight_smile:

Please let me know if you have any question, I still have my question about the recurring workflow for m y calendar.


Thanks for sharing. I think you’re correct in pointing to a flaw of this approach when you want exact answers: it does not account for leap days.

Why I believe that’s the case: you mention you’re 40 and a gap of 10 days. Since leap years occur once every four years, then you would expect to accrue 10 leap days over 40 years (with some minor variation).

So, you may not be able to accrue for it exactly, but you could adjust to add the 365.25.

Just remember you may also have some variation differences that may arise out of time zone differences and timestamps. (Splitting hairs, but to the extent it’s important).

Dan’s correct. (There really oughtta be a “:format as years” that would do the correct calendar-based math without having to worry about it. The leap year issue is probably why that operator isn’t available.)

Anyway, at least you know the number of days is right, eh? (If it were not you wouldn’t have detected any fractional error.)

Also, my original point stands: you can, of course, always compute the interval between two dates.

1 Like

Hi Dan,

Makes sense and basically does the same as what i suggested: you make a field on the database for the age ( be it a bucket) so you do not also have to do that calculation when you want to make the chart. @keith wondered if there would even be a usecase for this.
My personal interest is I’m facing a similar situation: I need data to plot a chart, and that data can already be derived from data in the database via a calculation, but maybe because of my limited knowledge of Bubble, I’m inclined to just store the data in already calculated form as an extra field ( in the example here: ‘Age’), so making the chart with “Group by” is easy.

1 Like

Just for confirmation, what happens when you delete the thing the recurring event uses as parameter?

1 - Does the next recurring workflow for that thing (and therefore all following ones) get cancelled?
2 - Doest the next recurring workflow for that thing run one last time and doesn’t reschedule itself because it fails to run properly?
3 - Or do we have to take care of cancelling it upon deleting that thing because it would continue to try running every time (without parameter)?

I guess (hope) it’s 1 or 2 :slight_smile:

Did some testing : the next scheduled wf stays visible in the scheduler even after the thing it takes as parameter has been deleted.

So it’s either 2 or 3…


Does anyone know what does this means?

Your plan currently only allows for 1 Recurring Event per Thing

Thanks a lot.

Use recursive workflows instead, works a lot better =)

1 Like

But recurring events are for monthly daily, monthly, etc. things right? Will recursive workflows work with events based on every month?