6 Replies Latest reply on Jun 22, 2011 8:38 AM by BatMan

    Perform AppleScript step timing out

    hiatts

      Title

      Perform AppleScript step timing out

      Post

      Hi,

       

      I am running a perform applescript step and it keeps timing out at 2 minutes with and without "with timeout" statements.

       

      The applescript does not time out when running in Script Editor (ie executing as native AppleScript).

       

      Is there some setting that filemaker uses to restrict all Applescript to 2 minutes? 

        • 1. Re: Perform AppleScript step timing out
          RickWhitelaw
            

          You should probably let the forum know if you're running the step as Native Applescript or Calculated Applescript and post the script if appropriate.  Two minutes is an awful long time for any single script to need. If you're more specific you'll likely get some help. As for your last question, I don't believe there's any special time limit that applies to Applescript specifically. If you have FMPro Advanced you can use the debugger. FMPro should (I think) report Apple event and Applescript errors as well.

           

          RW 

          • 2. Re: Perform AppleScript step timing out
            hiatts
               This is a calculated script, as in I pass a variable into Perform AppleScript.

            with timeout of 420 seconds

            try

            tellapplication "SAPGUI 7.10rev6"


            pressbutton "/app/con[0]/ses[0]/wnd[0]/tbar[1]/btn[8]"


            end tell

            end try

            end timeout

             

            2 minutes is very normal when running a report transaction in SAP.

             

            This script does timeout at 420 seconds when running via Script Editor, however when as Perform AppleScript in FMP only timeout values <= 120 seconds are accepted, and value greater than 120 seconds is ignored.

             

            I have placed timeouts and try statements in every and all places and nothing has managed to extend the timeout over 2 minutes. 


            • 3. Re: Perform AppleScript step timing out
              TSGal

              hiatts:

               

              There was a thread on this a couple of weeks ago:

               

              http://fm.lithium.com/fm/board/message?board.id=FM-en-4&thread.id=18965

               

              In essence, Perform AppleScript ignores a "with timeout" script and will timeout after two minutes.

               

              TSGal

              FileMaker, Inc. 

              • 4. Re: Perform AppleScript step timing out
                hiatts
                  

                For those dealing with SAP via AppleScript held in a FMP table, I wanted to share the work around on Filemaker Perform AppleScript being fixed at 2 mins (by bug in AppleScript API).

                 

                I do realise many of you do not deal with systems that can take >10 minutes to do a task, that is OK, please do not come back and tell me SAP is too slow. It is an enterprise system with very large amounts of data. It is normal. 

                 

                Description:

                I use FMP to run a transaction in SAP, wait for the report (it used to wait until SAP finished until a recent upgrade), then download the report, import to FMP, and slice'n'dice email it out etc.

                 

                The issue I encountered is that the With Timeout statement is not recognised when triggered from Filemaker Perform Applescript with a value > 120 seconds.

                 

                The workaround uses a loop in FMP that calls another AppleScript code that looks for a result in SAP. Unfortunately there is no "is processing" property for SAP GUI available to AppleScript, so I resorted to looking for a result, or a popup msgbox saying there is no result.

                 

                I also look for a 3rd result, if SAP kicks a timeout meaning it is not going to give you the report, it wants you to FTP it rather than present it on the GUI.

                 

                For those who may be facing a similar issue, here is the AppleScript, again I use a loop with a timed exit (10 mins) in FMP to continually check SAP GUI if there is a report, no data, or time out.

                 

                Cheers.

                 

                 

                • 5. Re: Perform AppleScript step timing out
                  hiatts
                    

                   

                  set txtResult to ""

                  set fResult to false

                  set txtNoResult to ""

                  set fNoResult to false

                  set txtSAPTimeOut to ""

                  set fSAPTimeOut to false

                  set gSAPTransactionCompleted to 0 as integer

                   

                  tell application "FileMaker Pro Advanced"

                  tell table "SalesOrgs"

                  set contents of field "gSAPTransactionCompleted" to gSAPTransactionCompleted

                  end tell

                  end tell

                   

                  with timeout of 1 second

                  tell application "SAPGUI 7.10rev6"

                  try

                  set txtResult to txt of label "/app/con[0]/ses[0]/wnd[0]/usr/lbl[2,1]"

                  if length of txtResult is greater than 0 then

                  set fResult to true

                  end if

                  end try

                  try

                  set txtNoResult to txt of text field "/app/con[0]/ses[0]/wnd[1]/usr/txtMESSTXT1"

                  if length of txtNoResult is greater than 0 then

                  set fNoResult to true

                  end if

                  end try

                  try

                  set txtSAPTimeOut to txt of label "/app/con[0]/ses[0]/wnd[0]/usr/lbl[0,0]"

                  if txtSAPTimeOut is greater than 0 then --contains "TIME_OUT" then

                  set fSAPTimeOut to true

                  end if

                  end try

                  end tell

                  end timeout

                   

                  if fResult or fNoResult then

                  set gSAPTransactionCompleted to 1

                  else if fSAPTimeOut then

                  set gSAPTransactionCompleted to 2

                  else

                  set gSAPTransactionCompleted to 0

                  end if

                   

                  tell application "FileMaker Pro Advanced"

                  tell table "SalesOrgs"

                  set contents of field "gSAPTransactionCompleted" to gSAPTransactionCompleted

                  end tell

                  end tell

                   

                  • 6. Re: Perform AppleScript step timing out
                    BatMan

                    Hi

                    I was wondering if anybody had a general workaround for this annoying issue. I need to be able to perform long tasks with the Perform AppleScript command.