An odd one >>Filemaker and Apple Script<<

So I wrote this code:
[Applescript]
tell application “FileMaker Pro”
tell database “MSpsi V1.4.fp7”
tell layout “Client”
get data from cell “Therapist”
end tell
end tell
end tell
[/Applescript]

And I got an “Does not exist” error from filemaker

I filled and farted with the script - testing different aspects. The Application, database and layout all are fine. Then I wrote this:

[Applescript]
tell application “FileMaker Pro”
tell database “MSpsi V1.4.fp7”
tell layout “Client”
count cells
end tell
end tell
end tell
[/Applescript]

and got a result of “0”

I changed the cells to fields and same thing. I changed the layout to one that another applescipt works on - same thing. Any thoughts…

Marcus

Two things. First, you’ve been caught out by the object hierarchy in FileMaker 7+. There is “database” and there is “document” (which is also generally the file name; extension is optional, if the file is open).

It is not a clean split, as some objects can belong to either (like “field”, which is similar to, but not the same as “cell”, which can also belong to either, but is used differently for each; yeah, confusing, but I’m sure there’s structural reasons for it.).

One thing that only belongs to “document” is “layout” (by name).* So, in your first try, if you change “database” to “document”, it will work.

You may want to add “of current record” at the end of the “cell” line. Otherwise you’ll always get the value from the 1st record (in the Found Set, when using “document” and “layout”).

FileMaker used to include much better documentation about AppleScript (as opposed to none now!). But it is still available:

http://fmdl.filemaker.com/MISC/fmp10/fp/apple_events_reference_wwe.zip

  • There are other ways to use “layout”, as in “layouts” (which is basically everything, all the data), or “name of layouts” (more useful); most of these can be used with either document or database; lots of overlap; but generally document is used for getting data from the current record (window can also be used).