Limitations running workflows on a list

Hi @josh,

Thank you very much for your answer. Although I read it as soon as you posted it, I did not have time to properly thank you for it.

A few thoughts:

  1. May I suggest that these concepts are incorporated into the “official” Bubble documentation? Most times it is difficult to find nuggets like this in the forum.

  2. On my original point 6, nesting: Nesting is a required feature in many situations but it allows me to schedule a large number of workflows in a short period of time by using it with no thought. Based on what you explained, I imagine that having a large number of workflows scheduled to run too close to each other and with complex queries inside would make them take longer and it could trigger Bubble to drop some if they are not properly spaced and the execution starts taking too long. Even though it may be obvious to most people, it may be worth warning in the documentation about this possibility. Frankly, my preference would be that Bubble slows the offending workflows to a crawl and not drop them – but that may not be easy to do from your side.

  3. It would be very useful if each workflow had access to 3 read only variables:

  • the number of items in the original list
  • the number of items already processed by the scheduled batch of workflows
  • the number of this workflow in the list
    This would be helpful to those who are trying to put logic dependent on whether this workflow is processing the first or the last element of the list. Right now, I’m doing a bit of a kludge to accomplish this (put it as a PS at the end of this message).
  1. It may be very useful to have the ability to cancel a runaway workflow once it started running.

Be well,

Alex

PS:
For those who care, you could do the following to know if the workflow is processing the last element in a list

a) Create a table called WFC (for workflow Control) with at least two fields: ListSize and ItemNumber.
b) Modify the workflow to accept a parameter (e.g. wfc) of type WFC
c) Add a step before scheduling the workflow to create a new thing (a WFC) setting ItemNumber to 0 and ListSize to the count of all the elements of the list that you will pass to the workflow when you invoke it (effectively running the same query twice, one now with a :count at its end and the second time when you invoke the workflow)
d) Schedule the workflow, passing the result of the previous step as the wfc parameter (or whatever you called it in step b).

e) As the first step in the workflow, increment the value of wfc’s ItemNumber by 1
f) When appropriate (I usually do it at the end of the workflow) put steps that are executed “only when” wfc’s ItemNumber" is wfc’s ListSize. This is what tells you that you are in the last element of the list.

g) you may want to cleanup WFC at this point of periodically because otherwise it will grow forever.

Hope this helps!

1 Like