5 Replies Latest reply on Jul 22, 2013 8:03 AM by thong127

    Close New window

    thong127

      Title

      Close New window

      Post

           Hello,

           Kindly help me with my script, I want the new window to be closed when I click CANCEL on my Custom Dialog Box. below is my script.

           IBS::Materials Report Selected = "API"

           Perform Script ["API"]

           Go to Related Record [Show only related records; From table:"Materials';Using layout:"API" (Materials);New Window

           Enter Preview Mode []

           Show Custom Dialog ["Print Options";"Would you like to Print or create a PDF"]

           If[Get ( LasMessageChoice ) = 1

           Show Custom Dialog ["Print Instructions"; "Pleasemake sure printing is set to Current Record and choose the printer you would lilke to print"]

           Print[Restore:\\Printer name]

           Else If [Get( LastMessageChoice ) = 2

           Show Custom Dialog [name your File"; Please Name Your File."IBS::Filename]

           If[Get ( LasMessageChoice ) = 1

           Sert Variable [$FileName Let(Name =Intelli Session::FileName & ".pdf";Case(Get(LastMessageChoice) = 1;

           "file:" & Get(DocumentsPath) & Name;Get(LastMessageChoice) = 2;"file:" & Get(DesktopPath) & Name;
           "file:" & Get(TemporaryPath) & Name))
            
           Print Setup [Restore;No dialog]
            
           Save Records as PDF [Restore;No dialog; $Filename'; records being browsed]
            
           Close Window [Current Window]
            
           Else If [Get ( LastmessageChoice ) = 3]
            
           Close Window [Current Window]
            
           End If
            
           End If
            
           End If
            
           Thank you in advance.
           thong

        • 1. Re: Close New window
          philmodjunk

               Is cancel button #3?

               You have two custom dialogs are you wanting to close the window if cancel is clicked in the first dialog or the second.

               I don't see any issues keeping button 3 from closing the window when clicked in the first dialog. If you have FileMaker Advanced, you might try enabling the script debugger and stepping through the script to see where the script fails and why.

          • 2. Re: Close New window
            raybaudi
                 ...
                 Show Custom Dialog ["Print Options";"Would you like to Print or create a PDF"]
                 If[Get ( LasMessageChoice ) = 3
                 Close Window [Current Window]
                 Else If [Get ( LastmessageChoice ) = 1]
                 ...
            • 3. Re: Close New window
              thong127

                   My Dialog Box look like this 

                   I want that if I dont want to continue printing or creating PDF, I will click the cancel buttonand the new window will close.

                   thong

              • 4. Re: Close New window
                philmodjunk

                     I wonder if you have posted your script accurately. Note what I get when I use ScriptPretty in The Known Bugs List database to pretty print your script:

                     Perform Script ["API"]
                     Go to Related Record [Show only related records; From table:"Materials';Using layout:"API" (Materials);New Window
                     Enter Preview Mode []
                     Show Custom Dialog ["Print Options";"Would you like to Print or create a PDF"]
                     If[Get ( LasMessageChoice ) = 1
                         Show Custom Dialog ["Print Instructions"; "Pleasemake sure printing is set to Current Record and choose the printer you would lilke to print"]
                         Print[Restore:\\Printer name]
                     Else If [Get( LastMessageChoice ) = 2
                         Show Custom Dialog [name your File"; Please Name Your File."IBS::Filename]
                         If[Get ( LasMessageChoice ) = 1
                             Sert Variable [$FileName Let(Name =Intelli Session::FileName & ".pdf";Case(Get(LastMessageChoice) = 1;
                             "file:" & Get(DocumentsPath) & Name;Get(LastMessageChoice) = 2;"file:" & Get(DesktopPath) & Name;
                             "file:" & Get(TemporaryPath) & Name))
                             Print Setup [Restore;No dialog]
                             Save Records as PDF [Restore;No dialog; $Filename'; records being browsed]
                             Close Window [Current Window]
                         Else If [Get ( LastmessageChoice ) = 3]
                             Close Window [Current Window]
                         End If
                     End If
                End If

                     That seems to show one more End IF than you should and that will trigger an error when you save this script.

                     In any case, it shows me the issue as you need to put an End IF just before the Else If [Get ( LastmessageChoice ) = 3] line so that  this Else IF is part of the first IF block, not the second one that is nested inside the first.

                • 5. Re: Close New window
                  thong127

                       Thanks Phil,

                       Your suggestion works! The Best Answer should be for Phil..not for my reply sorry.