# Loop - Defer

**URL:** <https://the.fmsoup.org/t/loop-defer/3993>\
**Category:** Heads-Up!\
**Tags:** scripting\
**Created:** [February 21, 2024, 10:55pm UTC](https://the.fmsoup.org/t/loop-defer/3993 "2024-02-21T22:55:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [February 21, 2024, 10:55pm UTC](https://the.fmsoup.org/t/loop-defer/3993/1 "2024-02-21T22:55:13Z")

</div>

Anyone using the new options in loops?

Right now there is a tinsy-winsy problem that Claris is aware of, and will have fixed in the next release.

**The issue:**  
When you use "minimum" or "defer" in a loop, after the loop finishes, FileMaker continues to defer evaluation of relationships. This will cause problems for anyone using Global fields on "this" side of the relationship. When you change the content of the global, the relationship isn't updated, and you keep seeing the old data.

**There is a Fix**  
After using "defer" in your loop, create a new, empty loop which has the "always" option. Inside the loop insert, exit loop[true]. That will switch off the "defer" flag, and your relationships will return to normal.

Basically, having a loop run with the "Always" option will switch the flag back to normal behaviour. It can be run from any script. It does have to run after the loop with "Minimum" or "Defer" options has finished.

```auto
Loop [flush: Defer]
  .... do your thing
End Loop
# defer flag should have been switched off, but it hasn't
# force the defer flag to be turned off
Loop [flush: Always]
  Exit Loop If [true]
End Loop

```

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [February 21, 2024, 11:36pm UTC](https://the.fmsoup.org/t/loop-defer/3993/2 "2024-02-21T23:36:29Z")

</div>

Great observation and great idea!

---

<div class="post-metadata">

**Author:** ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)\
**Post date:** [February 21, 2024, 11:52pm UTC](https://the.fmsoup.org/t/loop-defer/3993/3 "2024-02-21T23:52:47Z")

</div>

Thanks @Malcolm

- is the scope of the problem limited to the script that has the loop: Defer? Or does the issue persist in sub-scripts, and/or after the script has exited?
- has it been fixed in 20.3.2 ? Guessing "no", as it is not on the [Release Notes](https://help.claris.com/en/pro-release-notes/content/index.html)

---

<div class="post-metadata">

**Author:** ![jwilling](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/jwilling/32/256_2.png) [@jwilling](https://the.fmsoup.org/u/jwilling)\
**Post date:** [February 22, 2024, 1:47am UTC](https://the.fmsoup.org/t/loop-defer/3993/4 "2024-02-22T01:47:36Z")

</div>

I hope they release the fix soon.

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [February 22, 2024, 6:23am UTC](https://the.fmsoup.org/t/loop-defer/3993/5 "2024-02-22T06:23:03Z")

</div>

The issue is that the defer state persists after the script has finished. The whole file is in a defer evaluation state until you switch back to an always evaluate state.

The current release has the problem. If you haven’t updated to the release that introduces the defer state in loops then you might want to wait for the next dot point release.

---

<div class="post-metadata">

**Author:** ![FileKraft](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/filekraft/32/1183_2.png) [@FileKraft](https://the.fmsoup.org/u/FileKraft)\
**Post date:** [February 22, 2024, 3:37pm UTC](https://the.fmsoup.org/t/loop-defer/3993/6 "2024-02-22T15:37:50Z")

</div>

Great tip and idea using a placebo loop. (I use placebo scripts to clear script results to reset script result and grant the script result comes from the intended one ..)

Let’s pray they fix it soon. It is a new feature and should by now be fully baked IMHO.
