How to prevent infinite loop on rule triggered by formula field

I’m once again running into issues with loop detection in rules and humbly asking for some help.

Basically, I want to calculate the days in a sprint, and then create a “Day” entity for each of those days.

I thought a “Days Missing” > 0 filter would be enough to prevent the loop, but it’s still failing.

Here’s my rule logic:

Here’s the logic for for the formulas:

You won’t be able to avoid a loop using this method, since the Days Missing value will get changed every time a new Day is added (which happens when the automation runs).
If you want to create a batch of entities, where the number of entities in the batch is dynamic, the only safe way to avoid a loop is to use a script.
If your sprints are always the same length (=n) then you can write an automation with n actions, each of which adds a new day. Of course, if n = 100, then it’s probably not viable(!)

The loop detection heuristic is annoyingly unsophisticated :roll_eyes:
as complained about at length elsewhere.

It’s a tradeoff of sensitivity vs specificity - the more lax the logic on what triggers loop detection, the greater the risk of users’ automations causing performance degradation.
Given that most use cases can be solved with scripting for those inclined/able, it feels like the current balance is OK.
Having said that, examples like the one above would actually be better solved by directly allowing batch actions in (no-code) automations, rather than tweaking the loop detection to accommodate this particular implementation (requiring helper formulas and a repeating automation).

Yeah, adding the ability to loop automation actions without the need for scripts would be very helpful for people like me!

Until that feature someday comes, is there an example of a batch action script you could share that I could try and tweak to work for my current use case?

You can either use createEntity within a for loop, to generate each of the Days, one at a time, or you can use createEntityBatch and send an array of entity objects, one for each Day to be created.
See here: