Update List of items by date

Hi wonderful bubblers,

I got a problem that I really don’t know there is a solution for it.

So I have a list of activities with a “start_date”, “end_date”, “status” fiends saved in a database of my app.
I am trying to create some kind of logic: When current date > “end_date” then “status” is changed from “published” to “archived”.

I thought using backend workflows but I really couldn’t make it work, does anyone has another solution?

Thank you in advanced!

Hi @rafael.cunha,

Do you want to change an existing list of items that are already in the app (just as a one time event) or do you want it to automatically happen when that condition is true?

Hi @alanpieczonka, I want to change an existing list of items that are already saved in the database.
Once condition is true, status changes from published to archived.

@rafael.cunha
Okay, what is the approxemiated size of the list?

At the moment its on the 100’s but soon It will be on the 1000’s.

Since this condition is supposed to target only the “status = published” maybe there is a way to filter it… In that case it will keep being on 100’s, normally less.

@rafael.cunha,
There’s a lot of cleaner ways we could set it up, but if just a one time thing, here’s the most straightforward way to do this using (recursive) backend workflows:

  1. First, create a new backend workflow, ex.
    image
  2. Set up the first step, where you search for the activity with End date < current date and the Status of “Published” and change the Status to “Archived”
  3. Only when there are more activities like that (minus the activity we just updated) , call the same backend workflow from within this backend workflow
  4. Set up a button somewhere in the app and run it on click
  5. Run the workflow by clicking the button and give it some time to go through all of the records

Let me know if that makes sense

1 Like

@rafael.cunha You could also do it on the frontend using “Make changes to a list of thing”, but it isn’t as reliable as using backend workflows, especially with larger lists

1 Like

I will give it a try, is it possible to make it automatically so I don’t nee to click anything?
The step 5 is the main problem, it’s supposed to run automatically maybe I need to make a “Do every 5 seconds” workflow?

@rafael.cunha
If you want it to run automatically, on creation of a single activity, you can schedule a backend workflow that has a scheduled date of the end date of the activity, like that:


And then in the backend workflow


The only thing that I would add with this method is that you probably want to store the API workflow ID on particular activity so you can cancel/reschedule the workflow in the future if necessary.

1 Like

Thank you!