When is a list:count computed for a scheduled workflow?

I am creating a backend workflow that will run daily. One of the inputs is the count of a list in the database.

My question is “When is the list counted?” Is it when the API workflow is scheduled to run, or is it at the time of execution?

In other words, as my users work in the app throughout the day, the size of this list will grow/shrink.

When I schedule the workflow, I am using the count of this list as a parameter. I need to make sure that the list count will be counted only right before triggering the workflow, not a day before when it is scheduled.

UPDATE: After some testing, it seems like the count is counted when the workflow is scheduled. How can I pass the count of the list when the workflow runs?

I realize this is a single trigger of the workflow. In the workflow, after it is completed, it will schedule itself again just like this, only not using Results of step x.


Then do a search within the backend workflow.

Scheduling a workflow passes specific static parameters that can be used. For example, Scheduling a workflow that takes a list of Users (Do a search for Users) will be scheduled with the list of users that are searched for when scheduled. The workflow doesn’t treat the Users parameter as ‘Do a search for Users’ - no. It treats it as a list of users that were provided when scheduled.

If you want to get an updated count of users, just Do a search for users within the workflow (e.g Make changes to Thing’s field = Do a search for Users instead of Make changes to Thing’s field = Endpoint’s List of Users).

1 Like

Thanks. I was coming to this conclusion and just tried it. The problem is the workflow is recursive. It has a count parameter.

I’m trying to work out how to do this without the count searching on every iteration of the loop.

Also, it’s not a search exactly. I have Current User → Data Type → List Field. I suppose that is a search, but it’s just one field I need to count the contents of.

I don’t see how to set the Count parameter manually, and Bubble doesn’t have normal variables that I can just create and use…

Keep the “count” input, however when you schedule the workflo for the first time either leave it empty (set the checkbox for optional/allow empty), or just put any number in it. Whatever you do, dont run the search.

In the workflow,check whether the iteration is 1, if it is run the search instead of using the count parameter, if its not then use the count parameter.
When re-scheduling the workflow, use the “count” as input if the iteration > 1, and use the search if the iteration is 1 (or result of precious step to avoid rerunning the search. In general try to find a way to only run the search once and reference it in all future steps)

Thank you. I just finished a similar result. I’m still testing it to make sure it works correctly.

My initial API call when the new user first logs in is scheduled for the next day at 2:00 am. This workflow has no parameters.

When that workflow runs, it calls a second workflow with the parameters for my list and the count, iteration always starts on 1. This workflow only runs if the user is logged out.

If the user is logged in, it reschedules itself for one hour later.

Then once the second workflow runs, it has the correct list, the correct count, and the iteration starts a 1. At the end it calls itself count times (a loop) until the field on each Thing is changed from yes to no.

Then when it’s done, it schedules the first workflow again for 2:00 am the next day.

Is this a good way to do this or is there a better way to flip the boolean value of a field on multiple records?

Thanks for the input!

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