3 Replies Latest reply on Sep 4, 2012 4:15 PM by sporobolus

    External Applescript timing issue

    pthomas

      We are having an issue with an Applescript we use to extract data out of FileMaker and generate InDesign files.

       

      The Applescript is run outside of FileMaker.

       

      It seems that when the Applescript tells FileMaker to execute a script or other command, FileMaker reports that the call was successful as soon as the script/command has started executing, not once it has finished.

       

      This means that the Applescript moves onto its next step, which may not be able to run.

       

      e.g.

       

      Applescript calls FM script which performs a find, and sorts the results.

      Applescript then loops through the records processing them.

       

      The issue is that when the Applescript attempts to pull data out of the first record, FileMaker may still in the process of finding the data, so the Applescript falls over.

       

      This issue started happening with FileMaker 11 I believe, it did not seem to be a problem in earlier versions. After talking to our system administrator again he has confirmed this has always been an issue, it just seems to get worse with each new version!

       

      I don't develop or manage the Applescripts myself, but I believe our system administrator who looks after them has inserted "Delay X" commands all through his scripts to give FileMaker time to complete the requested task before his script moves on.

       

      My question is, has anyone else come across this sort of thing? And is there a way to fix it?

       

      If not, what other work around's have people had success with?

       

      The "Delay X" solution seems to work for the most part, but if there is any unexpected lag on the network when the process is run X may not be large enough so the script fails.

       

      One option we have had a look at is to have the FileMaker scripts always end by going to another layout, and then have the Applescript set up a loop checking if the layout name = that layout. Once the layout name matches the Applescript then moves back to the layout it wants to be on and continues processing. This is a bit of a pain to set up everywhere the Applescript may end up needing to wait for FileMaker though!

       

      Cheers,

       

      Paul.

        • 1. Re: External Applescript timing issue
          gdurniak

          Rather than a layout change, you could just set a Global Field after each FileMaker or Applescript action

           

          Then each would have a place to check if it's ok to move on

           

          greg

          • 2. Re: External Applescript timing issue
            pthomas

            Thanks Greg,

             

            Thats a good idea, I'll have a bit of a play around with it!

             

            Cheers,

             

            Paul.

            • 3. Re: External Applescript timing issue
              sporobolus

              on 2012-09-03 15:28 Paul Thomas wrote

              It seems that when the Applescript tells FileMaker to execute a script or other command, FileMaker reports that the call was successful as soon as the script/command has started executing, not once it has finished.

               

              This means that the Applescript moves onto its next step, which may not be able to run.

               

              (snip)

              This issue started happening with FileMaker 11 I believe, it did not seem to be a problem in earlier versions.

               

              I don't develop or manage the Applescripts myself, but I believe our system administrator who looks after them has inserted "Delay X" commands all through his scripts to give FileMaker time to complete the requested task before his script moves on.

               

              My question is, has anyone else come across this sort of thing? And is there a way to fix it?

               

               

              this is a known bug starting with FileMaker 11; it has been confirmed by FMI,

              but they don't call it a bug, they say it's just the same as every previous

              version, just "more noticeable"

               

              <http://forums.filemaker.com/comment/155867>

               

              you've got the gist of how to deal with it by creating some sort of reliable

              semaphore (e.g. layout change, global value change); another solution i've seen

              but not tried is to use the "modified" command in the AppleScript after steps

              that may behave asynchronously