To start I’ve tried to create this little script which was to give me the name of all cell (Fields) contained in document “Orders”
Next I wanted to display all record in document “Order” for which the Cell “OrderStatus” is equal to “C”
In running the script below I get an error -1728. Would someone have an idea?
Regards!
Daniel
tell application "FileMaker Pro Advanced"
--name of every database
tell database "wmyDatabase"
tell document "Orders"
choice of field "OrderNo"
show (every record whose cell "OrderStatus" = "C")
end tell
end tell
end tell
“tell document” within “tell database” should not work (and yields the same error on my machine). “tell” either the document to do something or “tell” the database.
One way that works to display records:
tell application "FileMaker Pro Advanced"
tell document "wmyDatabase"
go to layout "whatever_your_layout_with_that_field"
show (every record whose cell "OrderStatus" = "C")
end
end
FileMaker documents are a little unusual, in that FileMaker has what is called a “found set”, which are the “active” records (of a table; actually “table occurrence”). It also has “all” records.
The AppleScript term “database” refers to several application objects, and to “all” records. Whereas “document” refers to the “found set” of records. The term “window” shares many of the objects which “document” has.
As juergon points out, “database” vs “document” are separate, so you wouldn’t tell both of them at once like you did.
The script juergon proposed uses “document”, so it is targeting the found set. In FileMaker that would be the same as “Constrain Find”. So, while it may work for what you want, it will not work if what you’re looking for is not in the found set at runtime.
The first script is more like a real FileMaker Find, if you use ONLY “database”, not “document”. So just lose the “document” line. Though I wonder why the “document” is named differently from the “database”.
(I have no idea what the “choice” line is; “choice” is not a FileMaker object, it seems to be an undeclared AppleScript variable. I’d dump that line also.)
You can read about this stuff in this document, which used to be distributed by FileMaker in its installation, but isn’t anymore, for some obscure (and misguided in my opinion) reason: