6 Replies Latest reply on Jan 27, 2009 10:30 AM by CS8

    FM10 "upon opening" script not running when file is not opened directly

    CS8

      Summary

      FM10 "upon opening" script not running when file is not opened directly

      Description of the issue

      Hello, My database consists of 8 files + 1 file serving as a general menu. Within the general menu are several buttons that call scripts written inside the related files. I call these scripts directly from the general menu, through the "Perfom script" / "from external file" action.With this method I noticed that in FileMaker 10 the "upon opening" scripts defined in each of one of the target files are not run anymore when not opened directly (I tested with FileMaker 9 and they do run even though they don't show in debug mode). The opening scripts basically write to a table of global fields which includes the username and date of access to the file. This table is used in several relationships across the database and if not correctly populated causes the malfunctioning of the whole application. The only way of making it work with version 10 is to use the "open file" action and then "Perform script / from external file".This behaviour was reproduced under Mac OS X 10.5.6. I haven't tested it under windows.Can someone confirm and tell me if this change was intentional? I am afraid of having to deal with this across the entire application as it is already in production with several clients and they all intend to move to 10 soon.Kind regardsCS8 

        • 1. Re: FM10 "upon opening" script not running when file is not opened directly
          TSGal

          CS8:

           

          Thank you for your post.

           

          Unfortunately, I cannot duplicate the problem on my iMac running 10.5.5, but I'm only doing this with three files.  In my two sub-files, the scripts steps are:

           

          Enter Browse Mode []

          Go to Records/Request/Page [First]

          Set Field [<field>; "SUCCESS"]

           

          In the main file, I created a similar script but added the following two script steps:

           

          Perform Script [<opening script> ; <file 2> ]

          Perform Script [<opening script> ; <file 3> ]

           

          Both files were opened, and "SUCCESS" was written into the appropriate fields.

           

          Since these are opening scripts, "Open File" script steps also work, too.

           

          If you could give me more specific instructions, I will try and duplicate the problem here.

           

          TSGal

          FileMaker, Inc. 

          • 2. Re: FM10 "upon opening" script not running when file is not opened directly
            CS8
              

            Hi TSGal

             

            I don't think the problem is with the number of files. I'm actually running these script steps:

             

            From main_menu.fp7 (the main file) one of the buttons is linked to the orders.fp7 file and the action is defined as follows:

             

            Perform Script [<orders_internal_script> ; <file orders.fp7> ]

             

            Inside orders.fp7 the script ordes_internal_script has the following script steps:

             

            Enter Browse Mode[]

            Go to format [orders]

            Show all records

            Order records

             

            As you can see this script is not the one that is supposed to run when orders.fp7 is opened for the first time. the "upon opening" script is defined as follows:

             

            Enter browse mode[]

            Go to format [parameters]

            Define field [username_access] -> "Get (AccountName)"

            Define field [date_of_access] -> "Get (CurrentDate)"

             

            This one script should be run everytime orders.fp7 is opened for the first time. With filemaker 9 this is the case (although, as I said, the script will not show up in debugging mode in either version 9 or 10). With filemaker 10 it is not run unless you place an "open file" (orders.fp7) statement somewhere in the scripts.

             

            I think what you tried to do was perfoming the opening script by calling it directly from another script. This is ok but not my case.

             

            Apologies if any of the instructions above are written incorrectly, I'm developing under italian language and guessing their english equivalent.

             

            If you need further information I can send you an empty clone of the database.

             

            Regards

             

            CS8

            • 3. Re: FM10 "upon opening" script not running when file is not opened directly
              TSGal

              CS8:

               

              Thank you for the additional information.

               

              Here is some additional information from me....

               

              I created a second script in the second file that does:

               

              Enter Browse Mode []

              Go to Layout [<same layout> ]

              Go to Record/Request/Page [First]

              Set Field [<field #2> ; "Called script" ]

               

              In the first file, I changed the reference to the second file.

               

              In FileMaker Pro 10, like you, I did not get any value from the opening script.

               

              In FileMaker Pro 9, I also did not get any value from the opening script.  That is, the opening script also did not execute with FileMaker Pro 9.

               

              In order for this to work, I had to add:

               

              Open File [ <file #2> ]

               

               

              TSGal

              FileMaker, Inc. 

              • 4. Re: FM10 "upon opening" script not running when file is not opened directly
                CS8
                  

                Hi TSGal,

                 

                I further investigated the scripts inside the database files and can confirm your findings. Since I only debugged the "upon opening" scripts I was mislead into thinking the problem was there.

                 

                However, I figured that the problem is caused by the script step: "Open New Window". In filemaker 9 this seems to call the upon opening script as I tested with two simple files. In FileMaker 10 this does not happen.

                 

                If you could try the following simplified procedure I'd be grateful:

                 

                In the second file create a script that does:

                 

                Enter Browse Mode []

                New Window

                 

                and call this script from the main_menu directly and without any "open file".

                 

                What i've seen in FileMaker 9 is that when it comes to New Window it runs the "Upon opening" script. For some reasons in 10 I can't get this behaviour.

                 

                Thank you for your time.

                 

                Regards

                 

                CS8

                • 5. Re: FM10 "upon opening" script not running when file is not opened directly
                  TSGal

                  CS8:

                   

                  Thank you for the additional information.  I can see the difference between the two.  However, which one is correct?

                   

                  I have reported the difference to our Development and Software Quality Assurance (Testing) departments, and when I receive a reply, I'll let you know.

                   

                  In the mean time, use the Open File command to execute the opening file scripts.

                   

                  TSGal

                  FileMaker, Inc.

                  • 6. Re: FM10 "upon opening" script not running when file is not opened directly
                    CS8
                      

                    That's a good question. In my opinion FileMaker 9 behaviour is the correct one. Obviously because our application was developed and tested around that behaviour. In addition to that, I can see that the upon running script is run only once after the first time we call "New Window" on a script. I guess this is because FileMaker stores a flag of whether the file has been opened directly and if it's the first time it runs the upon running script. Maybe in FileMaker 10 this flag has been removed and New Window does not evaluate that condition. (calling a script from another file does not open that file yet, although you can see it and work with it).

                     

                    My 2 cents :)

                     

                    Looking forward to hearing from you once you have got some feedback from development

                     

                    Kind regards

                     

                    CS8