Import Records automation in FileMaker scripts
BeginnerAutomate CSV and XML record imports from scripts, control field mapping, detect import errors, and handle duplicates with a match field strategy.
What you'll learn
- How to script an Import Records step with a pre-mapped field order
- How the "Update matching records" option works as an upsert
- How to detect and report import errors
- How to validate the import count against an expected count
- When to use Import Records vs a script that reads a file line by line
Import Records is one of the most powerful batch data operations in FileMaker -- and one of the most error-prone to script. The field mapping is stored in the script step at authoring time, which means file structure changes break the import silently. Pair every Import Records step with Get(LastError) checking and post-import validation to catch mapping drift.
Configure and script an Import Records step
The Import Records step stores the source file path, format, and field mapping at the time you author the script. Build the source path dynamically and pass it into the step using the "Specify file" option with a calculated path.
Set Variable [ $importPath ; Value: Get ( DocumentsPath ) & "clients_import.csv" ] Set Error Capture [ On ] Import Records [ No dialog ; Source: $importPath ; Add new records # Field mapping set in step dialog (cannot be changed at runtime) ] Set Variable [ $importError ; Value: Get ( LastError ) ] If [ $importError != 0 ] Show Custom Dialog [ "Import failed (error " & $importError & "). The file may be missing or the format has changed." ] Exit Script [ Text Result: "error" ] End If
Sign in to track your progress and pick up where you left off.
Sign in to FM Dojo