4 Replies Latest reply on Mar 30, 2009 8:12 AM by philmodjunk

    Server Runs "Perform on Open" Script



      Server Runs "Perform on Open" Script

      Description of the issue

      FMS 10 on Windows Server 2003, sp2 I'm not sure if this is a bug or simply behavior I didn't expect. After getting a series of errors logged after test running a schedule set to perform a Filemaker Script, I did some experimenting. I created a simple script that modified a few fields that I could easily examine to confirm whether the script ran correctly.In File options, this file is set to run a script called "Log In" when the file is opened. The test script does not refer to "Log In" in any way.I created a schedule in FMS to run the test script.I ran the schedule and examined the log.I found the following error: Schedule "server test" scripting error (4) at "filename : Log In : Open File".I then used File Options to deselect "Log In" as a Perform on open script and repeated the above test.No errors were found in the log. Apparently, server triggers any script set to Perform on Open automatically. Is this expected behavior? As far as I know there is no way to detect that the script is being performed by server instead of a client. Therefore, if this is expected behavior, it severely limits my ability to use server to schedule a script.

        • 1. Re: Server Runs "Perform on Open" Script



          Thank you for your post.


          When FileMaker Server opens a file for hosting, it is not opening the database as a client.  FileMaker Server is merely acting as a conduit for the FileMaker Pro clients so that they can open the database remotely, so FileMaker Server itself does NOT run the On Open script when it opens the file.  However, when the Script schedule runs, the thread that runs the schedule acts as a FileMaker Pro client, and thus runs the On Open (and On Close) scripts.



          FileMaker, Inc.

          • 2. Re: Server Runs "Perform on Open" Script

            And there lies the problem. My "on open" script may need to use server incompatible script steps that abort or otherwise interfere with the performance of the scheduled script scheduled script even gets started. As far as I know, there is no way for the on open script to determine if it was launched because a human user opened the file.




            Now that I think about it. Get(currentuser) probably returns a different value for a scheduled perform script thread than does a "client" machine no? And Get(accountname) may be even better. I'm not sure from what I read in the help file, but its worth some experimenting.

            • 3. Re: Server Runs "Perform on Open" Script

              Well I ran the test I mentioned in my previous post and will now accept this post as a solution to the issue.


              When the script is being performed by the server,


              Get(username) returns the name of the script being performed.

              Get(AccountName) returns Admin.


              Thus the script step...


              If [Get(UserName) = Get(ScriptName)]


              should enable me to keep "Perform on Open" scripts from executing when a schedule kicks off a script for me.

              • 4. Re: Server Runs "Perform on Open" Script



                When the script is launched by a server schedule, Get(UserName) returns the name of the Schedule, not the script.




                If[Get(UserName) = "ServerScheduleName"]


                is the effective test to detect whether a script is being executed due to a scheduled script or by a human user's actions.