I’m setting up my first backend workflow, which I’m hoping is relatively simple but I’d like confirmation that it’s set up as intended.
I have a field that logs the date when a user last updated their measurements in my system. I want a backend workflow that triggers when that date is more than 6 months old. Here’s how I have it set up:
Maybe instead of a recurring, as I think you’ll be forced to ‘start’ it and set an interval such as daily, weekly etc… which is the nature of the recurring backend.
Perhaps, create a normal backend workflow, which you schedule when the user updates their measurements, and the scheduled date would be current date + 6 months. Then on that normal backend workflow use a conditional to double check the modified date + 6 months is less than the current date/time to only actually run it if the last modification is more than 6 months prior.
Interesting. I expected that it would recur on a regular basis in that it would regularly look for any date more than 6 months from the current date. But the Bubble documentation on recurring workflows isn’t super clear to me on that.
When you say a normal backend workflow, can you should me an example of what you mean? These are the options I see:
I tried setting up a trigger-based event, but I don’t think that’s right since nothing is actively changing—time has just passed since a data point in the database.
Trigger needs an event to trigger, usually a change in data…this could be used in your use case to schedule another API workflow (regular backend workflow) and the schedule would be current date +6 months.
Recurring event is something that happens on intervals, like daily, weekly, monthly and needs to be started via a trigger…usually used for things like sending a newsletter or something
API workflow is what I called a regular backend workflow.
I’ve read the documentation on workflow API but I’m bringing some pre-existing expectations to the table. In my brain, an API is external to my app but it seems like that’s not necessarily true in this case. Are Bubble API backend workflows self-contained then?
I started working on one and got stuck pretty quickly in terms of understanding how to get an acceptable date and how to tell the workflow to look for all users that meet that condition and act on their data:
Nothing wrong with your brain…it is just Bubble is not very good with naming conventions generally
Can be, and can not be…based on your settings for them within your app for the API settings as well as for individual backend workflows
You want to set it up so it looks at one specific entry in the database already, which means having a parameter of the entry to send through to the backend workflow. On that you can set a condition to run only if that parameter (the specific entry sent) has a modified date that is older than current date + 6 months.
Last year I needed a workflow like this too and at that time there were a couple of users complaining about scheduled workflows disappearing (maybe related to an outage).
Nico, instead of scheduling a new workflow for every user 6 months in advance, you can also use 1 workflow that runs on a daily basis and goes over the list of users and does 2 things:
It retrieves the users that have that measurement modification date that is more than 6 months from the current date. It triggers for those users a second workflow that performs the actions that you require (use schedule workflow on a list for that).
It reschedules itself to be executed again the same time tomorrow (or next week etc).
In case this scheduled workflow disappears you only have to restart 1 workflow, instead of multiple workflows (one for every user).
This is called a recursive workflow (not be be confused with a recurring workflow). This Youtube video shows how to do this: https://youtu.be/DMWC3p_avdQ?t=1109 from around 18.25.
Thanks for posting that video—I backed it up to watch from the beginning and something I hadn’t understood yet was that the scheduling component of this should be part of the workflow I have set up for a user saving their measurements:
Then my backend workflow is simple: it checks that the affected user has a setting that confirms they want this workflow to happen (they could’ve changed their mind at any point from saving until the scheduled workflow fires 6 months later):
And then the changes that happen just reset their measurement data to 0.
I think this is set up well now but let me know if you think I’ve overlooked something here. I assume my only option for testing this is to set my time period on scheduling to be like minutes later.