1 2 Previous Next 15 Replies Latest reply on Dec 16, 2016 10:00 AM by philmodjunk

    "Return" from FileMaker dialogs?

    JeffJ

      How can I get some form of "return" from the Print Setup[] script step that tells me if the user selected cancel on that dialog? I have tried the Get(LastError) and Get(LastMessageChoice) functions but they don't work for FileMaker dialogs. Thanks

        • 1. Re: "Return" from FileMaker dialogs?
          skywillmott

          The trick here is to use two 'Print Setup' script steps, and also having 'Set Error Capture' turned ON...

           

          In the first Print Setup script step, make sure you have the desired setup options selected (page size etc), and also that the script step is set to 'Perform without dialog'. Then in the second 'Print Setup' script step, make sure that 'Perform without dialog' is OFF and also that the 'Specify page setup' checkbox is also OFF... When the script is run, the second print setup dialog with have the same settings you specified in the first one.... You will then get an error 1 when the Cancel button is pressed if you use Get(LastError)... Your script would look something like:

           

          Set Error Capture [ On ]

          Print Setup [ Restore; No dialog ]

          Print Setup [ ]
          If [ Get(LastError) > 0 ]

               #user cancelled.

          Else

               #user clicked OK

          End If

           

          • 2. Re: "Return" from FileMaker dialogs?
            JeffJ

            That is brilliant! Who would have thunk it? Thanks so much. While I have your ear allow me to ask another. The script I am working on has to do with printing what could be a large group of invoices, each with related records in a line item table. I am attempting to provide the option to preview each invoice before printing and have a choice of continuing the operation, skipping the printing of the invoice being previewed, or cancelling the entire operation. The problem is very limited button functionality in preview mode. So far I can only think of a custom menu solution or a customized Status Area in FileMaker Pro 11 Advanced. Can you think of any other solutions? Is there a way to hide the Layout Bar section of the Status Area? Thanks again!

            • 3. Re: "Return" from FileMaker dialogs?
              skywillmott

              No problem :-)

               

              For your print, skip, or cancel routine, how about going into Preview Mode, hiding the toolbar and then showing a custom dialog with the options of printing, skipping and cancelling? The script would be something like:

               

              Enter Preview Mode

              Show/Hide Toolbars [ Hide ]

              Show Custom Dialog [ Title: "Print"; Message: "Would you like to Print this invoice?" ]

              # show dialog with Print, Skip and Cancel options

              If [ Get(LastMessageChoice)=1 ]

                   # do the print and move to next invoice

              Else If [ Get(LastMessageChoice)=2 ]

                   # do not print and move to next invoice

              Else If [ Get(LastMessageChoice)=2 ]

                   # cancel routine

              End If

              Enter Browse Mode

              Show/Hide Toolbars [ Show ]

              • 4. Re: "Return" from FileMaker dialogs?
                skywillmott

                oops... error in my script... the last Get(LastMessageChoice) should be:

                 

                Else If [ Get(LastMessageChoice)=3 ]     -- i.e. a 3 not a 2

                • 5. Re: "Return" from FileMaker dialogs?
                  JeffJ

                  Thanks again! I like it, I'll try it!

                  • 6. Re: "Return" from FileMaker dialogs?
                    JeffJ

                    Almost worked! The problem is the Show Dialog function does not pause the script and allow for checking the choice. If I hide the status area I have no visual way to continue the script after pausing it, and definitely no way to check for a choice. Thanks again though!

                     

                    P.S. I thought for a moment that running a sub-script to show the dialog might pause the current one but that is only an option for a button that runs a script.

                    • 7. Re: "Return" from FileMaker dialogs?
                      JeffJ

                      Ooops! Your solution was more brilliant than me. I forgot to refresh window after freezing and entering preview mode. I just wasn't seeing what I expected. Thank you again. If you would care to look it over I can send a print out of the entire script that prints a set of found invoices, with related line items, as separate "jobs", with or without preview, and several points to cancel the operation and return gracefully.

                      • 8. Re: "Return" from FileMaker dialogs?
                        jbardwell

                        However did you discover that? Glad to find your post! Thanks.

                        • 9. Re: "Return" from FileMaker dialogs?
                          philmodjunk

                          I've never needed to do that. Just turned error capture ON, Opened the dialog and then captured the error code immediately after.

                           

                          See my demo. If you click the button, the print set up dialog opens. If you click oK or press return, the custom dialog will tell you that OK was clicked. If you click cancel or press esc, the dialog tells you that cancel was clicked. To my knowledge, this works with all dialogs that you can open via script and in all platforms.

                          • 10. Re: "Return" from FileMaker dialogs?
                            skywillmott

                            Ah Phil, try changing your Print Setup script step so that it has the 'Specify page setup' option turned on, so it is:

                             

                            Print Setup [ Restore ; With dialog: On ]

                             

                            When that is set then error capture seems not to work.....

                            1 of 1 people found this helpful
                            • 11. Re: "Return" from FileMaker dialogs?
                              philmodjunk

                              Thanks, that's the difference. Looks like a bug to me.

                              • 12. Re: "Return" from FileMaker dialogs?
                                jbardwell

                                Phil, thanks for chipping in. I also created and tested with a demo file. I agree with skywillmott that it happens when "Restore" is turned on. I haven't tested other FM dialogs.

                                • 13. Re: "Return" from FileMaker dialogs?
                                  TSGal

                                  All:

                                   

                                  Thank you for your posts.

                                   

                                  If the Print Setup script step contains the Restore option, then canceling will have no effect because the Restore has already occurred, and in this case, FileMaker cannot set Get(LastError) to 1.

                                   

                                  TSGal

                                  FileMaker, Inc.

                                  1 of 1 people found this helpful
                                  • 14. Re: "Return" from FileMaker dialogs?
                                    skywillmott

                                    Thanks for clearing this up - makes sense :-)

                                    1 2 Previous Next