Perform Find: scripting finds and handling error 401

Beginner

Learn how to script a find in FileMaker using Enter Find Mode and Perform Find, set find criteria in variables, and gracefully handle the common error 401 "no records found" result.

What you'll learn

  • The three-step pattern: Enter Find Mode, Set Field criteria, Perform Find
  • How to handle error 401 (no records found) without crashing
  • How to use Perform Find [Restore] for a saved find request

Scripted finds use Enter Find Mode to create a find request, Set Field to enter criteria, and Perform Find to execute — always followed by a check for error 401, which means no records matched.

1/3
1

Script a find with criteria

Enter Find Mode switches to find mode. Set Field sets the criteria. Perform Find executes the request and returns to browse mode with the matching records.

FileMaker Script
Set Error Capture [ On ]

Enter Find Mode [ Pause: Off ]
Set Field [ Contacts::status   ; "Active" ]
Set Field [ Contacts::lastName ; "Doe" ]
Perform Find []

Set Variable [ $error ; Value: Get ( LastError ) ]

If [ $error = 401 ]
  # No matching records — not a hard error
  Show All Records
  Exit Script [ Result: True ]
Else If [ $error ≠ 0 ]
  Exit Script [ Result: $error ]
End If

# Found records are now in the found set

Sign in to track your progress and pick up where you left off.

Sign in to FM Dojo