Help with looping a workflow

Hi, would someone kindly take a look at my workflow and let me know where I’m going wrong please. I followed the YouTube video by @MattN " Recursive workflows in Bubble (OR, HOW TO LOOP THROUGH A LIST)" (which was great by the way) and added a final step to start the workflow again 1 day later, once the count of my RG was reached.

The first day works great, but I’ve clearly made an error with the final step as today I received the same emails again.

First two steps are send an email and make changes to a thing. Attached are screenshots of the API workflow, the penultimate step which loops the workflow and the final step where I’d like to run this all again for the updated RG the next day.

Any guidance is greatly appreciated as always

What is the ‘Payment Breakdown’?

Hi Adam, it’s a data type in my data base, storing payments . Has an amount, due date, paid date, status, client etc

And how do the emails relate to that?

Do you just have a single Payment_Breakdown entry in the database?

My users clients have a few payments each and the email is being sent 3 days before their due dates. My RG is a list of all the clients with payments that are due 3 days ahead. Each payment has a separate entry in the database

What I’m trying to get at is, you said the emails you got sent after 24 hours were the same as the ones you received the previous day, yes?

So what were they supposed to be, and where were they supposed to come from that would make them different from the previous day’s emails?

What does the ‘Send email’ action look like?

Yeah, it’s like it stored the same information.

Here’s the workflow for the send email and a screenshot of the RG (excuse the lack of styling it’s just for testing) that changes daily and I’d like the workflow to make its way through the RG list and send an email for that day’s outstanding payments, and email will be from the user

Ok, I see…

So the workflow’s payment_breakdown parameter is a list of Payment Breakdowns…

Presumably, you’re defining that list the very first time you schedule the workflow, right?

But then you’re just passing that same list into subsequent iterations of the workflow, so it will never change - it will just keep running over that same list, as it was defined the first time you scheduled the workflow - which explains why you got the same emails.

If you want to the list of Payment Breakdowns to be different each day, you’ll need to define a new list for each day… preferably at the time the workflow is about to start (if you want it to be as up-to-date as possible).

Yes, sorry I wasn’t clear, thanks for persevering.

The RG itself updates daily, so how do I define it as a new list?

You just need to redefine it each day in the backend workflow (instead of just using the same list each day).

The best way to do this would be to use 2 workflows…

One that runs over the list, and another that defines the list, triggers the other workflow to run on that list, then reschedules itself to run again the next day.


Workflow B

Takes a list of Payment Breakdowns and and index as parameters.

Action 1: Send an email to the ‘index’ item from the list.

Action 2: Make changes to your thing.

Action 3: Reschedule Workflow B to run on the next item in the same list, until the list is complete.

Workflow A

Action 1: Schedule workflow B to run, and define the list for it to iterate over.

Action 2: Reschedule workflow A to run again in 24 hours time.

Perfect, that’s exactly what I was missing. Will set that up.

Appreciate your help

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.