I’ve written several AppleScripts that work with Filemaker databases. The scripts usually involve searching database files for records and if not found will insert records into multiple tables.
I’ve noticed that sometimes, I have to perform a search manually in FileMaker and then select show all to get my script to work properly. Otherwise the script search seems to find a match to the first record in the database.
I’m guessing that somehow when I manually perform the search, that Filemaker refreshes the index on the [primary key] search field.
Is there a way that I can have AppleScript tell FileMaker to re-index fields? I’m thinking this would make sure that the search that would follow it would always work accurately.
If you use 'tell document myDoc" your search will be performed on the current records.
You must use ‘tell database myDoc’ to make a search on all records.
If the above dont help, post one of your script here, and tell us what versions of Mac OS and FM you run.
I am using “tell database…” as you mentioned. Here’s a snippet of the script…
tell application "FileMaker Pro"
tell database irisWorks
set cell "Work No." of request 1 to workNumber
find window 1
if (exists (cellValue of cell "Work No." of current record)) then
Sorry I don’t include the entire script but it is very long and includes several user-defined functions, one of which includes that code above.
I’m developing on OS 10.3.4 with Filemaker 6.x and the test box I’m running it on is OS 10.2.8 with Filemaker 6.x. I’m hoping that my script will run on any OS X system.