False detection of "infinite loop" in Formula field

This Formula was detected as an infinite loop:

[Dependent On] is a collection of this same Type (Task). But I see no way this could actually be causing an infinite loop, unless the entity was linked to itself in this collection – which it is not.

This is probably caused this Formula’s interaction with a Rule that changes the State field in response to a change in this Blocked Formula field. If so, the error message is leaving out some important information :slightly_frowning_face:

The potential infinite loop:

  • A State change on Task1 causes recalculation of the “Blocked” Formula in its dependent Task2:
    Blocked = [Dependent On].Filter(State.Final = false).Count() > 0

  • Task2’s changed “Blocked” value triggers the “Task is Unblocked” Rule.
    This updates Task2’s State field (when it becomes Unblocked, it may change State from Waiting to Progress).

But this will only cause a loop if Task1 and Task2 are circularly dependent via the [Dependent On] collection, which would only occur by mistake.

I can see why a heuristic would flag the situation. But is it possible to refine the heuristic to be more discerning about “possible vs actual” infinite loops?

Interestingly, after I edited and re-saved the Rule, although I did not actually CHANGE it, everything now works as it should – no more error. :thinking:

I may just be offering unwelcome suggestions here but would a better formula be

([Dependent on].filter(State.final = false).Count() > 0) or ([Dependent on].filter(Blocked = true).Count() > 0)

?

In other words, a Task is blocked if the Tasks it depends on are not done, or if they are blocked (which implies that the Tasks they depend on are not done, or they are blocked (which implies that the Tasks they depend on are not done, or…) )

Note: The ability for a formula to refer to itself in a related entity is not offered by the field autocomplete engine, but it is supported.

1 Like

I simplified the formula for this post – the actual Blocked formula is

(State.Final = false) and ([Dependent On].Filter(State.Final = false).Count() > 0)

The Blocked field doesn’t need to be explicitly checked by the formula, since it is necessarily false for a Task that’s Done.