Bulk operations design in FileMaker scripts
ExpertDesign large-scale batch scripts that handle errors per-record, report progress, respect user cancellation, and finish with a summary report.
What you'll learn
- How to build a progress indicator for long-running scripts
- How to accumulate per-record errors and continue processing
- How to implement a safe early-exit checkpoint
- How to produce a post-run summary report
- How to use a staging table for operations that must be reversible
A bulk operation -- updating prices, reassigning records, sending emails to a segment -- runs across hundreds or thousands of records. A poorly designed bulk script fails silently, leaves records in a half-updated state, and gives the user no feedback. A well-designed one processes records individually, accumulates errors without stopping, reports progress, and delivers a complete summary.
Show live progress during a bulk operation
Update a progress field (or a global field on a visible layout) every N records to give the user real-time feedback. Updating every record is expensive; updating every 50 records is a good balance.
Set Variable [ $total ; Value: Get ( FoundCount ) ]
Set Variable [ $processed ; Value: 0 ]
Set Variable [ $errorCount ; Value: 0 ]
Go to Record/Request/Page [ First ]
Loop
# Do the per-record work
Set Field [ Products::Price ; Products::Price * $multiplier ]
Commit Records/Requests [ No dialog: On ]
Set Variable [ $err ; Value: Get ( LastError ) ]
If [ $err != 0 ]
Set Variable [ $errorCount ; Value: $errorCount + 1 ]
End If
Set Variable [ $processed ; Value: $processed + 1 ]
# Update progress every 50 records
If [ Mod ( $processed ; 50 ) = 0 ]
Set Field [ Globals::ProgressMessage ;
"Processing " & $processed & " of " & $total & " records..."
]
Commit Records/Requests [ No dialog: On ]
Refresh Window
End If
# Check for user abort
If [ Get ( LastError ) = 1 ]
Exit Loop
End If
Go to Record/Request/Page [ Next ; Exit after last ]
End LoopSign in to track your progress and pick up where you left off.
Sign in to FM Dojo