1 2 Previous Next 19 Replies Latest reply on May 23, 2016 6:06 AM by Fred(CH)

    OnFirstWindowOpen not fired

    Fred(CH)

      Summary

      OnFirstWindowOpen not fired

      Product

      FileMaker Pro

      Version

      13.0v3 and earlier

      Operating system version

      Mac OS X + Windows

      Description of the issue

      Perform a script from a FileMaker external data source can cause the OnFirstWindowOpen trigger failure.

      Steps to reproduce the problem

      STEP 1
      - Create two files, FileA and FileB.
      - Create a startup script on FileB.
      - Create another script on FileB to be called from FileA.
      - From FileA, create an external data source and add FileB as such.
      - On FileA, add a table from FileB on Relationship graph.
      - On FileA, create a script that performs the script from FileB as a subscript.
      - Close both Files
      STEP 2
      - Open FileA (FileB is closed)
      - Check the Windows menu Show Window sub-menu. FileB is hidden and indicated between brackets
      STEP 3
      - Perform the script from FileA (which execute the subscript from FileB)
      - Check the Windows menu Display Window. FileB is hidden BUT NOT INDICATED BETWEEN BRACKETS ANYMORE.
      STEP 4
      - Open FileB

      Expected result

      The startup script from FileB must be executed on step 4 or, at least, it had to be on step 3.

      Actual result

      The startup script from FileB was never executed, even if the enduser is now browsing on FileB.

      Consequence : globals not loaded, incorrect window's size, and more...

      Exact text of any error message(s) that appear

      -

      Configuration information

      Irrelevant.

      Workaround

      Complete the master script on FileA to detect if yes or no the FileB is already open. If not, close FileB at the end of execution. Thus, FileB will be shown between brackets and the startup script will be executed on next opening.

      That is to define, for instance, $closeB variable with this formula :
      IsEmpty ( WindowNames ( "FileB" ) )

        • 1. Re: OnFirstWindowOpen not fired
          Fred:
           
          Thank you for the post.
           
          I am able to replicate, following the steps provided, using FileMaker Pro 13.0v3 (Advanced) on both the Windows and Mac operating systems.
           
          Additionally, I forwarded a report to Testing and Development for review.
           
          TSFalcon
          FileMaker, Inc.
          • 2. Re: OnFirstWindowOpen not fired
            Fred(CH)

            Dear TSFalcon,

            Thank you for the ultra responsive answer smiley.

            First, I am interested to know if it is considered an issue or a bad practice.

            I also was wondering if a better workaround would be to use the Open File [Hide] command before performing the script.

            However, i cannot get it to work, since the opened file this way is shown anyway, in spite of the Hidden option.

            Please let me know when you have more information about it.

            Bye, Fred

            • 3. Re: OnFirstWindowOpen not fired
              philmodjunk

              This has long been seen as a somewhat desirable "feature" as it enables people who do not have FileMaker Advanced to get a file open when a rogue script performed by OnFirstWindowOpen would otherwise keep them locked out of their file.

              • 4. Re: OnFirstWindowOpen not fired
                Fred(CH)

                Thanks Phil for your answer.

                However, dont' know if it is my "language limit" or my "technical limit" but i don't understand it at all. In particular, the relation with FMPA, the sense of "rogue script" and "keep them locked out of their file".

                Are you sure you understood my post in spite of my poor english ? I can try again…

                I found very interesting the ability to perform a script from another file "silently" (don't know if this term is correct).

                But the counterpart is the *bug* i described : if then, the user want open the hidden file, the startup script won't perform and then, ton of other bugs can occurs.

                I thought it can help other users to know that and also, i hoped a feedback from FileMaker engineers to let me more understand the logic behind, and why not, provide a fix on a somewhat future release wink.

                Friendly, Fred

                • 5. Re: OnFirstWindowOpen not fired
                  TSGal

                  Fred:

                  Development is aware of this limitation.  The OnFirstWindowOpen script is triggered when the first window is created on a file directly (manually or via New Window or Open File script steps).  However, performing a script in another file does NOT trigger the OnFirstWindowOpen script (even though it must create a window) because this would severely interfere with the execution of the calling script.  If you need the OnFirstWindowOpen script to be triggered, use Open File script step prior to calling the script in that file.

                  TSGal
                  FileMaker, Inc.

                  • 6. Re: OnFirstWindowOpen not fired
                    Fred(CH)

                    Hello TSGal,

                    Thank you very much for the answer !

                    I am afraid i was not clear in my first post. I did not expect that the startup script will be fired when i ran my external subscript, since it did not create any windows !

                    I was just expecting the startup script to perform, after, when the user manually open the second file.

                    Fred

                    • 7. Re: OnFirstWindowOpen not fired
                      philmodjunk

                      A "rogue script" that I am referring to would be a file that never terminates due to being trapped in an infinite loop or that immediately closes the file or quits FileMaker. Note that some execute to quickly to abort  via keyboard shortcut and they all might deny such aborts with the allow user abort script step.

                      Thus, unless you have FileMaker Advanced so that you can enable the script debugger and open the script debugger--where you can abort the script in the debugger, you have no other way to get the file open such that you can correct or remove the "rogue" script.

                      • 8. Re: OnFirstWindowOpen not fired
                        Fred(CH)

                        Dear visitor,

                        You maybe are here because you are running onto one of theses two different cases :

                         

                                                                                                                                                                                                                 
                        ProblemSolution
                        Sometimes, your OnFirstWindowOpen triggered script is not performed when the enduser open a file of a multiple file solution.You are surely running into this issue. You have a chance to solve it using the workaround i provided on appropriate section above.
                        You don't have access to FileMaker Pro Advanced, however you must open a file and prevent its wrong startup script to perform.You can try to replicate this issue (following the steps above and be sure to use a safe subscript). Then, you will be able to debug or remove your startup script.

                         

                        Special thanks to Phil for his explanations and patience.

                        Sincerly,

                        Fred

                        • 9. Re: OnFirstWindowOpen not fired
                          JeroenAarts

                          Hi,

                          I found this post after running into the same issue with 'Go To Related Records (Use External Table's Layouts)' from file A to file B. Even tough a window from file B becomes visible, the 'OnFirstWindowOpen' script trigger is not fired.

                          Regards,

                          Joris Aarts - ClickWorks

                          • 10. Re: OnFirstWindowOpen not fired
                            Fred(CH)

                            The OnFirstWindowOpen script is triggered when the first window is created on a file directly (manually or via New Window or Open File script steps).  However, performing a script in another file does NOT trigger the OnFirstWindowOpen script (even though it must create a window) because this would severely interfere with the execution of the calling script.

                             

                            However, i recently noticed that a server side script DO fire the OnFirstWindowsOpen. Is this the expected design regarding since not any real windows is created (only virtual) and it could also be severely interfere with the execution of the caulking script, moreover if incompatible scripts are implied on the startup script.

                            Workaround : systematically test PatternCount ( Get ( ApplicationVersion ) ; "server" ) at the beginning of your starter script.

                             

                            • 11. Re: OnFirstWindowOpen not fired
                              TSGal

                              Fred:

                              Yes, this is expected design.  Perform Script On Server launches a new client on the server that can open files directly, so the OnFirstWindowOpen script executes.

                              TSGal
                              FileMaker, Inc.

                              • 12. Re: OnFirstWindowOpen not fired
                                Fred(CH)

                                Thank you. And i think this behavior is a good thing in absolute.

                                But that put in perspective that i definitely cannot understand the reason why we can so easily "hack" the OnFirstWindowsOpen trigger when a script is executed on a FileMaker Pro's virtual window. I say "hack", because if you understood, once the external script was executed, the OnFirstWindowsOpen of external file will never be fired anymore, even if you try to use an Open file step !

                                Is PhilModJunk right, saying it is to solve special situations where the triggered script is a rogue script ?

                                Just love learning and overall understanding…

                                Fred

                                • 13. Re: OnFirstWindowOpen not fired
                                  TSGal

                                  Fred:

                                  If the external script executes, the file has been indirectly opened and the OnFirstWindowOpen will not execute.  Not until you close the file and open it again will OnFirstWindowOpen script execute.  However, if the file is part of a relationship, the file will remain open and cannot close, so you would have to call the OnFirstWindowOpen script directly.

                                  I understood the "rogue script" from PhilModJunk is a script that gets into an infinite loop and cannot be aborted.  Phil - can you answer this for Fred?

                                  TSGal
                                  FileMaker, Inc.

                                  • 14. Re: OnFirstWindowOpen not fired
                                    Fred(CH)

                                    Thank you, but Phil has already answered about signification of rogue script --  yes : infinite loop.

                                    But i was just wondering if that special case of "troubleshooting bad script" was indeed the original reason /justification of a such design or not, a fact that only the designer could answer...

                                    Fred

                                    1 2 Previous Next