10 Replies Latest reply on Apr 7, 2015 10:36 AM by Diver

    Yosemite broke AppleScript getting content of a field

    Diver

      I have written several Applescripts to get the content of FileMaker fields that worked in several past versions of FileMaker and the Mac OS.   Yosemite came along and this process no longer works.   A quick search reveals that there were changes in Applescript with system 10.10 but I am unable to identify what will fix the Applescripts.  I have been using Apple's Script Editor for troubleshooting the problem.

       

      Here is a sample of what the script looks like:

       

      tell application "FileMaker Pro Advanced"

        set filePath to the contents of field "fieldnamehere" of table "tablenamehere"

      end tell

       

      Here is the result:

       

      error "FileMaker Pro Advanced got an error: Object not found." number -1728 from contents of field "fieldnamehere" of table "tablenamehere"

       

      I have validated the Applescript works fine when running under system 10.8.x and system 10.9.x with the same FileMaker database. 

       

      I welcome all suggestions.

        • 1. Re: Yosemite broke AppleScript getting content of a field
          mikebeargie

          None of the changes to applescript in 10.10 really had an effect on filemaker afaik.

           

          1728 is a pretty generic error, indicating that the reference to what you are trying to grab was not found. Is there more to the script you are not posting? First I would just go through and make sure all the references are correct (case sensitive as well) to any database, layout, table and field names. But you've probably already done that.

           

          Nothing comes to mind as to a root cause based on an upgrade. Do other applescript calls to FMPA work? EG:

          tell application "FileMaker Pro Advanced"

            show database "yourdatabase"

          end tell

          • 2. Re: Yosemite broke AppleScript getting content of a field
            Diver

            Mike, thanks for the suggestion.   I tried the 'show database "your database"' as you suggested from Apple's Script Editor and it brought the database to the foreground perfectly.  You are correct in saying there is more to my Applescript but for debugging I narrowed it down at this point to just trying to set an Applescript variable to that of a FileMaker field.

             

            I have the database being mentioned hosted on a FM 13 server.  I use two different machines on the network, one running Mac OS 10.8.5 and the other running system 10.10.2 and both running Filemaker 13.0v5.  I run the same FileMaker script on both.  The 10.8.5 machine runs the FM Script, which in returns performs an AppleScript, and it works flawlessly.   I do the same thing on the 10.10.2 machine and it errors.   I then copied and pasted the Applescript into Apple's Script Editor on both machines and confirmed that the 10.8.5 machine works and the 10.10.2 machine does not.   This should eliminate the database (hosted), The version of Filemaker (both 13.05) and that it is the Applescript, not FileMaker, because it fails in Script Editor.  I have also tried this same process on my laptop which is running system 10.10.2 on it and it fails.

             

            Looking through old posts on the web it looks like Applescript with FileMaker use to use something different then 'contents' when working with FileMaker fields.  The older posts showed the command of:

             

              set filepath to cell "fieldnamehere" of table "tablenamehere"

             

            I tried this and low and behold, I think it worked.  I can't do a full test until I can take production database offline but I am hopeful. If it does work, apparently there were two ways to previously set an Applescript variable from FileMaker but now only one way works.

            • 3. Re: Yosemite broke AppleScript getting content of a field
              mikebeargie

              hmm, I didn’t think the cell operator was compatible anymore with Filemaker, vs. using field. My applescript is pretty rusty though, good to hear you might have a working solution.

              • 4. Re: Yosemite broke AppleScript getting content of a field
                electon

                According to the Library table contains fields, records, cells.

                field contains cells, repetitions.

                I've always referred to the contents of a field by calling to the cell and never seen an example of "contents of field".

                • 5. Re: Yosemite broke AppleScript getting content of a field
                  monkeybreadsoftware

                  Are you sure the script is right?

                   

                  tell application "FileMaker Pro Advanced"

                    return field "textField" of table "test"

                  end tell

                   

                  works fine here.

                  • 6. Re: Yosemite broke AppleScript getting content of a field
                    fmp

                    If you want the results from a  single record, this has been reliable for me:

                     

                    tell application "Filemaker Pro Advanced"

                    tell window "windowname"

                    tell layout "layoutname"

                     

                    get data cell "fieldname" of current record -- field must be on the layout referenced

                     

                    end tell

                    end tell

                    end tell

                     

                    If you want a list of all the values in a particular field of a table, try using:

                     

                    tell application "Filemaker Pro Advanced"

                    get data field "fieldname" of table "tablename"

                    end tell

                     

                    If you want a list of all the values of a field across only the found set, you can refer to "document":

                     

                    tell application "FileMaker Pro Advanced"

                    tell document "windowname" -- there is  a found set showing

                    tell layout "layoutname"

                     

                    get data field "fieldname"

                     

                    end tell

                    end tell

                    end tell


                     

                    ps I'm still on Mavericks.

                    • 7. Re: Yosemite broke AppleScript getting content of a field
                      Diver

                      A quick update....

                       

                      There is still something funny going on.  It has been working for 2 days while I have been doing development work.  Today, after working for several hours in the database and using the Applescript code in my scripts, it stopped working. I started getting similar Applescript error as my original post outlined.  

                       

                      I did a simple test from Apple's Script Editor as Mike mentioned above and it worked fine.

                       

                           tell application "FileMaker Pro Advanced"

                             show database "yourdatabase"

                           end tell

                       

                      This has me believing that FileMaker was still responding to Applescript commands.  I then tried the AppleScript from Apple's Script Editor that fmp listed he uses and it also failed.

                       

                      Finally I quit FileMaker Pro Advanced and reopened and all started working.  I wonder if it is FileMaker, Applescript or Yosemite that might be causing the problem.  I have no doubt that I may have tweaked some Applescript code that did not work so perhaps that caused something behind the scene to break things but I would hope that bad AppleScript could not cause it to partially break with no warning.   Is it possible for an AppleScript to still be running invisibly and cause trouble but other Applescripts could still be run at the same time?   I am now faced with the possibility of users reporting FileMaker is not working properly but it might actually be Applescript not working properly.  Any suggestions on how a person could run an Applescript script to see if it is working properly with FileMaker?  This would at least allow a error trap so the user could be told they have to restart FileMaker to resolve it.

                      • 8. Re: Yosemite broke AppleScript getting content of a field
                        BruceRobertson

                        When using the table reference make sure the field you are referring to is a global field.

                        • 9. Re: Yosemite broke AppleScript getting content of a field
                          BruceRobertson

                          What's the bigger picture - why are you using Applescript in the first place?

                          • 10. Re: Yosemite broke AppleScript getting content of a field
                            Diver

                            Having FileMaker integrate with an accounting package that does not have any FM Plugin options.