1 2 3 Previous Next 61 Replies Latest reply on Aug 21, 2015 2:18 AM by thomasseidler

    Applescript fails in FileMaker 11.0v2

    jjackson+fm@pobox.com

      Summary

      Applescript fails in FileMaker 11.0v2

      Product

      FileMaker Pro

      Version

      11.0v2

      Operating system version

      10.6

      Description of the issue

      An applescript that uses the "do script" will fail with an error as the script doesn't seem to complete before the next command is accepted.

      Steps to reproduce the problem

      Set up a test database ("Test"). Give it a field, a layout ("Test"), and set up two scripts that do something (such as go to  the layout, but in different views so you can see a change.)

      Using the Apple Script Editor, create and use applescript code similar to:

      tell application "FileMaker Pro Advanced"
           tell document "Test"
                go to layout "Test"
                do script "Go to layout as form"
                   do script "Go to layout as list"
           end tell
      end tell

      Expected result

      The script should run to the end without an error and the layout should be left in list view. Works fine in version 10.

      Actual result

      Instead, in version 11, hangs at line

      do script "Go to layout as list"

      Exact text of any error message(s) that appear

      --> error "Data is being accessed by another user, script, or transaction." number -10011

      Workaround

      No workaround known at this time.

        • 1. Re: Applescript fails in FileMaker 11.0v2
          TSGal

          John Jackson:

          Thank you for your post.

          Although this worked in FileMaker Pro 10, did this also run with FileMaker Pro 10 under Snow Leopard? (There were some changes in Applescript with Snow Leopard).

          Also, what are the contents of the scripts "Go to layout as form" and "Go to layout as list".

          If you move the second script into its own tell section, does this work?  That is,

          tell application "FileMaker Pro Advanced"
          tell document "Test"
          go to layout "Test"
          do script "Go to layout as form"
          end tell
          tell document "Test"
          go to layout "Test"
          do script "Go to layout as list"
          end tell
          endtell

          Any additional information you can provide may be helpful in narrowing down the possible cause(s).

          TSGal
          FileMaker, Inc.

          • 2. Re: Applescript fails in FileMaker 11.0v2
            BruceRobertson

            There is no error, there is no change in behavior, and the script works correctly as written.

            However if you have not committed the record, you will get the error. This is normal. You can add a "save" command at the top of the script. That's the same as commit record.

            • 3. Re: Applescript fails in FileMaker 11.0v2
              jjackson+fm@pobox.com

              #TSGal:

              1. "did this also run with FileMaker Pro 10 under Snow Leopard?"

              Yes.

              2. The contents of the "Go to layout..." scripts are similar; the last one is:

              Go to Layout ["Test"]

              View As [ View as List ]

              (I tried eliminating the first line (Go to Layout ["Test"] ) to no effect.)

              3. I tried this (adding tell blocks around the "do scripts") and found no change.

              But what would make it work is this: if I added a delay of 1 second between the steps

              tell application "FileMaker Pro Advanced"
              tell document "Test"
              go to layout "Test"
              do script "Go to layout as form"
              delay 1
              do script "Go to layout as list"
              end tell
              endtell

              then it worked. That seems consist with other reports (see http://forums.filemaker.com/posts/4b2544f7a4) that applescript in FM11 is not completing steps prior to starting new ones. 

              Is it (the FM11 applescript) multi-threaded?

              "There were some changes in Applescript with Snow Leopard." Do you have any information on these changes?

              # Bruce Robertson: The record has been committed, and adding a Committ Record step made no difference. It appears to be a timing problem.

              • 4. Re: Applescript fails in FileMaker 11.0v2
                TSGal

                John Jackson:

                Thank you for the additional information and taking the time to try things out and document this further.

                I have forwarded your posts to our Development and Software Quality Assurance (Testing) departments for review and confirmation.  When I receive any news, I will let you know.  In the mean time, it appears you have found a workaround with the "delay 1" step.

                TSGal
                FileMaker, Inc.

                • 5. Re: Applescript fails in FileMaker 11.0v2
                  jjackson+fm@pobox.com

                  @TSGal

                  You wrote:

                   In the mean time, it appears you have found a workaround with the "delay 1" step.

                  Actually, no. That's not really a work-around. True, it works in this example, but in general one could not use it because unless you knew how long a script took to complete, you wouldn't know how long to pause. (It's also true an elaborate system of semaphores using files could be employed, but an easier solution is to just not upgrade past FM 10.)

                  So until it's fixed, Applescript is basically useless.

                  • 6. Re: Applescript fails in FileMaker 11.0v2
                    TSGal

                    John Jackson:

                    Testing wants to know if you have any script triggers associated when switching layouts.  This might send a busy error back to the Applescript.

                    TSGal
                    FileMaker, Inc.

                    • 7. Re: Applescript fails in FileMaker 11.0v2
                      jjackson+fm@pobox.com

                      No script triggers are used when switching layouts.

                      • 8. Re: Applescript fails in FileMaker 11.0v2
                        TSGal

                        John Jackson:

                        Thanks for the clarification.  I've reported this information back to Testing.  I'll continue to keep you updated.

                        TSGal
                        FileMaker, Inc.

                        • 9. Re: Applescript fails in FileMaker 11.0v2
                          BruceRobertson

                          Perhaps we shouldn't have to do it; but the current fix is to add a repeat statement that confirms you have actually landed on the layout. With this approach you do not have to add a delay and then worry whether it is long enough.

                          set L to "TEST"
                          repeat

                          try

                          go to layout L

                          ifnameofcurrent layoutisLthenexitrepeat

                          endtry

                          endrepeat

                          • 10. Re: Applescript fails in FileMaker 11.0v2
                            BruceRobertson

                            Might even be considered just good robust defensive programming. Could also be turned into a handler - on goLayout( theLayout)

                            Bruce

                            • 11. Re: Applescript fails in FileMaker 11.0v2
                              VerneArase

                              The problem is that FileMaker is returning control to the AppleScript before the action is completed (asynchronous vs. synchronous). As FileMaker cannot handle multiple AppleScript commands running simultaneously, the script errors out.

                              The solution would be for FileMaker not to return control until the action is complete.

                              If FileMaker could handle multiple commands simultaneously, it would still need to supply some kind of semaphore mechanism so completion of past commands could be tested (or waited on), but I believe this is a bug and not a conscious design change.

                              Placing arbitrary maximum duration delays in your processing turns a very fast FileMaker into a very slow one, and negates the performance increases the developers have built into later versions of the product.

                              • 12. Re: Applescript fails in FileMaker 11.0v2
                                jjackson+fm@pobox.com

                                Verne Arase wrote:

                                The problem is that FileMaker is returning control to the AppleScript before the action is completed (asynchronous vs. synchronous). As FileMaker cannot handle multiple AppleScript commands running simultaneously, the script errors out.

                                The solution would be for FileMaker not to return control until the action is complete.

                                I'd agree with that if it was changed to "FileMaker 11" instead of just "FileMaker". "FileMaker 10" didn't do this; it doesn't return control until the action is complete. This behavior broke in the move from 10 to 11.

                                • 13. Re: Applescript fails in FileMaker 11.0v2
                                  BruceR

                                  But the solution has already been provided. Loop until the intended layout is selected. No need for delay.

                                  • 14. Re: Applescript fails in FileMaker 11.0v2
                                    VerneArase

                                    Yes, FileMaker 11 broke synchronous execution of AppleScripts. All prior versions waited until the command completed execution.

                                    And no, looping doesn't fix it ... it just masks the problem and wastes CPU time. That kind of solution would probably trick my laptop into clearing two virtual cores and drive the remaining two into overclock mode.

                                    Besides which, having to design your code so that it can detect whether the do script has completed is simply ludicrous.

                                    Here's the URL pointing to how I was burned by this bug: http://forums.filemaker.com/posts/3b3b412bd5.

                                    1 2 3 Previous Next