# False detection of "infinite loop" in Formula field

**URL:** <https://community.fibery.io/t/false-detection-of-infinite-loop-in-formula-field/2972>\
**Category:** Bugs & Issues\
**Created:** [June 17, 2022, 10:15pm UTC](https://community.fibery.io/t/false-detection-of-infinite-loop-in-formula-field/2972 "2022-06-17T22:15:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [June 17, 2022, 10:15pm UTC](https://community.fibery.io/t/false-detection-of-infinite-loop-in-formula-field/2972/1 "2022-06-17T22:15:53Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/7/7343287775fc4af8399fbe76f76737945f12e3f8.png)

This Formula was detected as an infinite loop:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/7/72dbccc4094e247ee55aeed3532ce7d88c9959f5.png)

`[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.

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [June 17, 2022, 10:20pm UTC](https://community.fibery.io/t/false-detection-of-infinite-loop-in-formula-field/2972/2 "2022-06-17T22:20:21Z")

</div>

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 🙁

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?**

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [June 18, 2022, 5:29am UTC](https://community.fibery.io/t/false-detection-of-infinite-loop-in-formula-field/2972/3 "2022-06-18T05:29:09Z")

</div>

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. 🤔

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [June 18, 2022, 12:45pm UTC](https://community.fibery.io/t/false-detection-of-infinite-loop-in-formula-field/2972/4 "2022-06-18T12:45:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [June 18, 2022, 3:36pm UTC](https://community.fibery.io/t/false-detection-of-infinite-loop-in-formula-field/2972/5 "2022-06-18T15:36:00Z")

</div>

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.
