AnsweredAssumed Answered

AppleScript can't find global field if table has no records

Question asked by botfixer on Aug 23, 2018
Latest reply on Aug 31, 2018 by beverly

In my solution I created a table called "globals" for all my global fields. I wrote some AppleScript to call "do shell script" to report some info about the filesystem and store the results in a global field in this table. But the script failed, saying "Object not found." and "Unknown error: -10006.", even though I copied the scripts and tables and fields exactly from the sample solution in this discussion:Applescript to shell script to field


After a half-day of investigation I discovered the cause, which I believe is a FileMaker bug. If an AppleScript attempts to access a global field whose table has no records, you get this error. But if you add one "dummy" record to the table, even though it only contains global fields, then it works as expected.




Product and version: FileMaker Pro Advanced

OS and version: Mac OS X El Capitan (10.11.6)

Hardware: Mac Pro 5,1 (classic)

Description: AppleScript can't find global field if table has no records

How to replicate: Load attached file and click "Run" -- get error. Now click "New Record", and then "Run" -- no error, see "test" in zResult.

Workaround: always have at least one "dummy" record in the table with all your globals




complete repro steps from scratch are as follows:


1. new project

2. create table "globals"

3. create two global text fields "zScript" and "zResult" (text boxes should auto-appear on "globals" layout, if not, create them)

4. create a button "Run" on the layout with a script that does "Perform AppleScript", calculated, with field globals::zScript

5. paste the following script into zScript field:


set cell "zResult" of table "globals" to "test"


6. File > Manage Security > Extended Privileges, and add "fmextscriptaccess"

7. notice that the Records total for "globals" is 1, but we are only using global fields, so click "Delete Record" and confirm

8. click "Run"

9. get errors: "Object not found." and "Unknown error: -10006."

10. if you add back a single record by clicking "New Record", then click "Run", it works and you get "test" in zResult




The FileMaker UI automatically creates a dummy record for you in step 3. But if you are an obsessive developer who realizes the dummy record is not necessary for a table of all global fields and remove it, your AppleScripts start breaking in mysterious ways.