11 Replies Latest reply on Aug 20, 2010 2:32 PM by donjuancarlos_1

    Capturing close issue

    donjuancarlos_1

      Title

      Capturing close issue

      Post

      I have a Windows filemaker 11 server environment with about 15 Filemaker 11 clients.

      I did the custom menu thingy to capture a close event.  The problem I am having is that about 8% of the time, the event does not seem to be captured and the script does not run.  Does anyone know why this might be happening or how to make it more robust?

        • 1. Re: Capturing close issue
          philmodjunk

          We'll need more details. How did you set this up? What script did you create?

          By a "close" event are you closing a specific window or an entire FileMaker file?

          • 2. Re: Capturing close issue
            donjuancarlos_1

            Okay, now I see where the problem is coming from, but I'm not sure of the way to fix it.

            The Estimating department uses Filemaker for creating quotes.  When they close the window, a script runs that performs different actions based on the window name, and updates other related databases. 

            What the problem seems to be is that Estimators are closing Filemaker when they are finished a quote by hitting the Red X in the upper right corner of the window.  I know how to run a script when closing, but--is there a way to systematically run a script for each open window and shut the windows one-by-one when closing the file?

            • 3. Re: Capturing close issue
              philmodjunk

              In otherwords, run a script at application close if a specific window is open and don't if it's not?

              Use this step to capture a list of open window names in a variable:

              Set Variable [$OpenWindows ; Value: WindowNames ]

              Then you use IF steps like:

              If [ Not IsEmpty ( FilterValues ( $OpenWIndows ; "Estimator" ) ) ]

              To run a section of the script (or call a sub script) only if a window named Estimator was open at the time Filemaker was exited.

              • 4. Re: Capturing close issue
                donjuancarlos_1

                Okay, getting closer, now I have one more situation that must be addressed.  It is possible for Estimators to have multiple quote windows open simultaneously.  The title of each quote window is: Building Quote [quote #]

                I would have to do some sort of loop and close the windows 1 by 1. If my only options to select windows is either current or by the exact name, how would I select each window?

                • 5. Re: Capturing close issue
                  philmodjunk

                  Since this script is performing when the the application exits, why do you need to close any windows? Don't you just need to do the "on close" housekeeping tasks for each such window?

                  After all, since filemaker is shutting down at this point, the windows are going to close anyway...

                  • 6. Re: Capturing close issue
                    donjuancarlos_1

                    Yes, but I need to run the script individually for each open quote.

                    • 7. Re: Capturing close issue
                      philmodjunk

                      Then you can loop through those and call the script once for each window. You can use select Window to select the window from your variable list and then perform the script.

                      • 8. Re: Capturing close issue
                        donjuancarlos_1

                        Yup, that's the part I don't understand.

                        Say I have the following Windows open that I pull into variable $OpenWindows

                        Menu
                        Building Quote 19685
                        Building Quote 19236
                        Building Quote 18293

                        I need to select each "Building Quote" window and run the script.  So I will do this

                        Loop

                        Select Window ?????

                        Perform Script "Labour Report"

                        End Loop

                        the ????? is the part I don't know how to do.

                        • 9. Re: Capturing close issue
                          philmodjunk

                          Set Variable [$OpenWindows ; Value: WindowNames ]
                          Loop
                                 Set Variable [$I ; Value: $I + 1 ]
                                 Set Variable [$WindowName ; GetValue ( $OpenWindows ; $I )]
                                 If [PatternCount ( $WindowName ; "Building Quote" ) > 0 ]
                                         Select Window [ Name: $WindowName ; CurrentFile ]
                                         Perform Script [//your script for that window]
                                 End If
                                 Exit Loop If [$I >= ValueCount ( $OpenWindows ) ]
                          End Loop

                          • 10. Re: Capturing close issue
                            RickWhitelaw

                            If your "Building Quote" layouts are based on the same table, why not run a script on closing (last window close) that does whatever you want to the records and let the windows close as they do anyway? Even if they're based on different tables, it's the data and layout (and the table it's based on) and not the window that matters IMHO.

                            RW

                            • 11. Re: Capturing close issue
                              donjuancarlos_1

                              GetValue ( $OpenWindows ; $I ) --- That's what I was missing.

                              Thanks PhilMod!!

                              Rick, I have to run the script in the current record of each open window.