Looping through a found set in FileMaker
IntermediateLearn the reliable counter-loop pattern for iterating through records. Understand why "Exit after last" is unreliable and how to build loops that always terminate correctly.
What you'll learn
- Why "Exit after last" on Go to Record is unreliable and causes infinite loops
- How to write the canonical counter loop pattern
- How to collect results into a JSON array during a loop
Looping through a found set is one of the most common scripting tasks in FileMaker. The built-in "Exit after last" option on Go to Record seems convenient but produces subtle bugs. The counter loop pattern is reliable, readable, and easy to debug.
1/4
1
Never use "Exit after last" on Go to Record
The "Exit after last" flag depends on an internal state that FileMaker does not guarantee will be set correctly after every operation. In practice, it can fail to exit, causing an infinite loop.
FileMaker Script
# DO NOT DO THIS: Loop # ... process record ... Go to Record/Request/Page [ Next; Exit after last ] # unreliable End Loop
FileMaker script error handling with Set Error CaptureFileMaker Set Variable — scope, naming, and when to use it
Sign in to track your progress and pick up where you left off.
Sign in to FM Dojo