3 Replies Latest reply on May 15, 2010 3:49 PM by PieroF

    Applescript working in FMP10 doesn't work in FMP11



      Applescript working in FMP10 doesn't work in FMP11


      Since I upgraded to FMP 11 Advanced, one of my scripts, including Perform Applescript, doesn't work any longer.


      The script is supposed to update a container field "Foto" by changing the pathname of its referenced file; the new pathname is in the text field "Path di Foto" and has a format like "Macintosh HD:Users:...".

      The FMP script contains only the Perform Applescript step, which runs the following native applescript:


      tell current record of document "Foto Mobili"

        set data of cell "Foto" to file (cell "Path di Foto" as text)

      end tell


      Up to FMP 10 the above script would update the picture in "Foto" without problems; starting with FMP11 each time I run the FMP script I get 2 error messages "Object or property of wrong type" and (after confirming the only OK button) "Unknown error -10001".

      After some debugging I found out that the problem seems related with the "file" keyword; if I simply remove it (set data of cell "Foto" to (cell "Path di Foto" as text)) the script doesn't show error messages, but it simply sets the path name itself into the container, not the photo with that pathname... I also tried to change it with "alias": same error messages.


      Since I couldn't find any solution in the FMP documentation nor in this forum I'd like to ask the following questions:


      1. is the applescript wrong (even if it worked in FMP10 and earlier) or is there a bug in FMP 11 ?


      2. is there any workaround for this, possibly without using applescript ?


      In fact I'd be happy to do without an applescript, if possible.


      Thanks in advance for your help




      (Sorry, by mistake I posted this same problem in the Provide Feedback forum, while it was supposed to be posted here)

        • 1. Re: Applescript working in FMP10 doesn't work in FMP11

          This works for me, in FileMaker 10 and 11.


          setpicto "Macintosh HD:Users:fej:Pictures:ART:Bouguereu:kiss.jpg"


          tellapplication "FileMaker Pro Advanced"

          setcell "pictureCon" ofcurrent recordtofilepic



          But what does not work is if I compile and run it in an AppleScript from outside FileMaker in 10. Then open FileMaker 11 and try to run it, or visa versa (even with the other app closed). Because AppleScript seems to remember which app it was compiled for, and insists on it. 


          You might try copying the guts of the AppleScript out of the Perform AppleScript step, pasting it into a new one, and see if that works.


          Another thing that sometimes helps when things like this go wrong is to separate the script slightly. Get the path to the file in one line, then set the container in another, rather than trying to do both at once. FileMaker seems especially touchy about this. I usually set the FileMaker data into a variable before doing anything else with it.

          • 2. Re: Applescript working in FMP10 doesn't work in FMP11

            Thanks for your suggestion.

            I will try it as soon as I can and let you know how it goes.



            • 3. Re: Applescript working in FMP10 doesn't work in FMP11

              OK, it works!

              Thanks for your answer.

              What didn't work any longer was the "tell current record ... end tell" statements.


              So I changed the original faulted script:

              tell current record of document "Foto Mobili"

                set data of cell "Foto" to file (cell "Path di Foto" as text)

              end tell


              set cell "Foto" of current record to file (cell "Path di Foto" of current record as text)


              This seems to work fine

              Thanks again! I've been trying to solve it for days... now it is working thanks to you.