Loop
Repeats a set of script steps, to perform batch processes.
See also
Options
Flush specifies when to flush cached relationships and update dependencies while in the loop:
-
Always: For every step in the loop that modifies data, always flush all cached relationships and update all dependencies. This is the default option and ensures related data is available as expected.
-
Minimum: For every step in the loop that modifies data, flush cached relationships and update dependencies on related data that are only one relationship away from the current table occurrence.
-
Defer: When the loop starts, use the currently cached relationships and data. Wait until the loop exits to flush cached relationships and update dependencies.
Compatibility
Product | Supported |
FileMaker Pro | Yes |
FileMaker Go | Yes |
FileMaker WebDirect | Yes |
FileMaker Server | Yes |
FileMaker Cloud | Yes |
FileMaker Data API | Yes |
Custom Web Publishing | Yes |
Originated in version
6.0 or earlier
Description
Use Loop, for example, for exporting container field contents from all records in a found set. This script step and the End Loop script step mark the beginning and end of a repeating structure of script steps. The script performs the script steps that are enclosed within the loop structure until it encounters one of the following:
- an Exit Loop If script step
- a Go to Record/Request/Page script step or Go to Portal Row script step when the Exit after last option is selected
Every Loop step must have a corresponding End Loop step somewhere after the Loop step and at the same indentation. Whenever you use a Loop script step, the script editing pane automatically enters an End Loop step.
Notes
-
Whether to change the Flush option depends on the design of your database. In general, if your loop doesn't modify data that affects relationships, then Defer can be the fastest option. But if it does modify such data and the data is only one relationship away, try Minimum instead. Otherwise, leave it set to Always. For more information, see this Claris Engineering Blog post.
Example 1
Copies the contents of the Customers::Work Phone to Customer::Day Contact in all records.
Go to Record/Request/Page [First]
Loop [ Flush: Always ]
Set Field [Customers::Day Contact; Customers::Work Phone]
Go to Record/Request/Page [Next; Exit after last: On]
End Loop
Example 2
Loops through records to export files that are in the Container field.
Set Variable [$PATH; Value: Get ( DocumentsPath ) & Products::Container]
Go to Record/Request/Page [First]
Loop [ Flush: Always ]
Export Field Contents [Products::Container; "$PATH" ; Create folders: Off]
Go to Record/Request/Page [Next; Exit after last: On]
End Loop