4 Replies Latest reply on Aug 31, 2015 8:48 AM by DavidJondreau

    Script for Window Close Issue

    AndrewJudd

      Hi All, anyone know why I have a window as part of a script which is not closing. It's the second one here? It only happens when there is only one record in the portal I am calculating. If explanation is needed, this is a script which calculates the total number of artworks on an invoice and then uses that number to work out how to split a discount evenly among them.

       

      The last window won't close so even when I hide it using the 100 100 - 200 -200 details the main window remain inactive until you click it - no good.

       

      I have just added the "not equal to 1 bit" in the hope that works but it doesn't.

       

      Any ideas?

       

      Thank you!

       

       

      Screen Shot 2015-08-31 at 11.37.41.png

        • 1. Re: Script for Window Close Issue
          erolst

          You could rewrite your script as:

           

          Allow User Abort [ off ]

          If [ IsEmpty ( ARTWORK::_fkInvoiceID ) ]

            Exit Script

          End If

          Set Variable [ $discount ; INVOICES::Discount After Production ]

          Go to Related Record [ ARTWORK ; Layout: Artwork ; matching only ; match current only ; New Window ]

          Replace Field Contents [ ; no dialog ; target field: ARTWORK::Split Discount ; calculated result: $discount / Get ( FoundCount ) ]

          Close Window

          • 2. Re: Script for Window Close Issue
            AndrewJudd

            Thanks so much

            • 3. Re: Script for Window Close Issue
              rrrichie

              You might have had more windows open than you "saw".  Especially when debugging and stopping a script halfway does this :-)

               

              I name my temp windows "temp" and when developing I have script at the beginning that closes all temp windows :-)

              • 4. Re: Script for Window Close Issue
                DavidJondreau

                Go to Record/Request[Exit after last]

                 

                This script step is the problem. The Exit after last option is commonly used inside a loop but when it's not, it exits the script. It's a bizarre little aspect. What's happening is when you have one record, that script step exits the script skipping the rest, including the Close Window[].

                 

                From the help:

                "Exit after last tells FileMaker Pro to stop the script when it reaches the last record in the found set. You can use Exit after last with the Loop script step to exit out of a loop after the last record."