12 Replies Latest reply on Mar 6, 2014 3:47 PM by lijnbach

    Close window immediately after delete record

    lijnbach

      Title

      Close window immediately after delete record

      Post

           I think it is something easy, but I can not find it.

           I open an new lay out in a new window. The new window is "Dialog". In this lay out only adding is allowed. So I open the window with a script "new record". Everything is working. 

           On this lay out I have a button to delete the record that was added (in case the user makes a mistake and wants to go back). Normally, after deleting the record, you get te next record in the lay out. I do not want users to change records in this lay out. So I made a simple script for the delete button: first delete the record and then close the window. Closing the window is not working after deletion. The strange thing is, that I have another button that only closes the window, that works fine.

           This is what I used. (Translated);

           Delete record [No Dialog]

           Close Window []

           I thought it had perhaps something to do with another script still running, but that is not the case. (I added "stop script", but with the same result.

           Can someone help me out with issue?

           Hans Lijnbach

            

        • 1. Re: Close window immediately after delete record
          philmodjunk

               That should work. Do you have FileMaker Advanced? If so, you can enable the script debugger and step through this script one step at a time to see if anything else (such as a script trigger) is interfering with the script.

               A simpler process might be to put only fields with global storage on this layout. When the user clicks a button to accept the new data ( "OK" or "Save"), that button's script can create the new record and use set field to transfer the data from the global fields to corresponding fields in the new record. That way there is no record to delete if the user chooses to cancel.

          • 2. Re: Close window immediately after delete record
            lijnbach

                 Hi Phil,

                 The problem with global fields is that in this lay out (with the corresponding table) I have other fields from related tables. I know some users can do strange things, so that is why I want them only to add a new record in this lay out, further nothing.

                 I checked the lay out and all the fields, but no script trigger is used in this lay out. (because it is only adding). And, no I don't have Advanced. (I am thinking about upgrading).

                 Last we had a discussion about security, what would it be nice to have the security, not only connected with users, but also with lay outs. So you can use lay outs for only viewing, only adding, only deletion etc. That would spare a lot of work.

                 It is strange that it is not working, the "close window" button is working fine, but in combination with "delete record" it is not working.

                 Thanks for your effort Phil, I will try to find a work around. (If I separate the script, one script for deletion and then go to another script for closing the window, it is also not working).

                 Hans Lijnbach

            • 3. Re: Close window immediately after delete record
              lijnbach

                   O.K. Phil,

                   I found something out; I gave "No Dialog" for deleting a record. But, if I delete the record, the dialog with the question "Are you sure you want to delete this record" keeps coming back. Can it have something to do with the window in "Modular" mode?

                   Hans

              • 4. Re: Close window immediately after delete record
                philmodjunk

                     That suggests that you have two different scripts and the script where you specified "no dialog" is not the script that you are actually performing when you click the button to delete the record and close the window. If this is what is happening here, it's another case where using Advanced's script debugger makes it pretty obvious when a script with different steps than what you expected pops up in the debugger.

                     Another advantage to using Advanced is that you could install a custom menu with this layout/modal dialog window where clicking the close window control in the corner of the window performs your script for deleting and closing instead of just closing the window.

                     As far as I'm concerned anyone designing FileMaker databases, whether an expert or a novice, should use FileMaker Advanced to do so. It's added developer tools can save you hours of frustration and at the same time teach new users more about how FileMaker works.

                • 5. Re: Close window immediately after delete record
                  lijnbach

                       O.K. Thanks Phil,

                       I think it will be better to upgrade. But I am sure no other script or script trigger is running. If I close everything and all lay outs, and just open this lay out, the same problem occurs. And this lay out (and all the fields) have no script trigger. (There is only a value list (based on a table) in the lay out).

                       But thanks for your effort Phil, I know you spend a lot of time on the forum.

                       Hans Lijnbach

                  • 6. Re: Close window immediately after delete record
                    philmodjunk

                         I am not suggesting another script trigger nor another script running at the same time (FileMaker can only run one script at a time anyway.) I am suggesting that given the message that is popping up, that you are not running the script that you think you are running. That's the only explanation that makes sense for getting a message asking to confirm deleting the record when you have selected the "no dialog" option for the delete record script step in the script that you edited.

                         Here's a demo file that creates a new record in a modal window and the cancel button both deletes the record and closes the window--with no confirmation dialog on the delete:  https://dl.dropboxusercontent.com/u/78737945/DeleteAndCloseTest.fmp12

                    • 7. Re: Close window immediately after delete record
                      lijnbach

                           Great Phil,

                           Thank you again for your effort.

                           Hans Lijnbach

                      • 8. Re: Close window immediately after delete record
                        lijnbach

                             O.K. Phil,

                             Finally found it. I used your script, and working. I looked at my script and compared both scripts. The only difference is that I first opened the lay out, and then shut down the menu. You first shut down the menu and then load the lay out. It makes no difference in normal lay outs, except when the window is a dialog window. I don't understand why, but it is working when I first shut down the menu.

                             Thanks again, now starting with conditional values. (I couldn't find it on the forum at first, but that is because it is called "invoerlijst beperken" in Dutch).

                             Hans Lijnbach.

                              

                        • 9. Re: Close window immediately after delete record
                          philmodjunk

                               I went back to my demo file and changed the new window script to reverse those two steps so that Show/Hide Tool bars comes before Go to Layout. It made no difference. I can still click cancel and the script both deletes the record and closes the window as expected.

                          • 10. Re: Close window immediately after delete record
                            lijnbach

                                 I also turned it back to my previous version (first open lay out, then hide Tool Bar) and it is not working anymore.

                                 Strange situation. But it is working with your version.

                                 Hans.

                            • 11. Re: Close window immediately after delete record
                              philmodjunk

                                   Either there is some other detail not the same or your script is damaged and should be replaced with a new script of the same steps.

                              • 12. Re: Close window immediately after delete record
                                lijnbach

                                     I deleted the script and build a new script with another name. Now it is working.

                                     Damaged script?

                                     Thanks Phil.

                                     Hans.