Since the data is in global fields, can't you just use new window re-open the window in order to "cancel the close"?
Hmm. Possible but not desirable. The global fields and variables are initialized when the window opens, so that data will be lost. Isn't there a way to cancel the close event itself? Thanks.
That depends on how you set up the action to close the window. and "The global fields and variables are initialized when the window opens," is something that you can modify so that this isn't driven by a script trigger on that window's layout.
A button to close the window can check before closing the window. And a custom menu where you have replaced the close window menu option--which is what is selected when you click the "close window" control in the corner of the window--that replaces the normal menu option with the same script can ask for user confirmation.
But you can't do this from the OnWindowCloseTrigger as the script is performed After the window close event is processed, so it's already too late by the time your script starts up.
See "Setting up Script Triggers" in FileMaker help to see a table of all script triggers and which ones are "before the event" triggers and which are "after the event" triggers. Only "before" triggers can use Exit Script [False] to cancel out the triggering event.
"The global fields and variables are initialized when the window opens," is something that you can modify so that this isn't driven by a script trigger on that window's layout.
How would I do this?
I'll check out the help files for the event trigger sequence. Thanks for the tip.
Presumably, you are performing a script to open the window in the first place. This script can include set field steps to clear the fields.
I frequently set up one script for opening such a window with a script parameter such that if Get ( ScriptParameter ) = "Clear", the script clears the fields. If it is not, it leaves them with current values. This allows me the option of re-opening the window without clearing the data. This is useful in some of my "Find record dialogs" as a find button can perform a script to open the window with the "clear" parameter and a Modify Find button can perform the same script to open the same window but without the "clear" parameter and then the user is able to modify the values in the fields without having to re-enter.