Loop - Defer

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.

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
14 Likes

Great observation and great idea!

1 Like

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

I hope they release the fix soon.

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.

2 Likes

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.

1 Like