Quick Tip: Adding an Exit All Button to Your Forms Menu / Toolbar

February 2, 2012

Alternative title: Eject me from the forms system fast! Close all forms without all those pesky validations.

This week a need arose at a customer site to exit all open forms (with one button click ) and return to the first form with the main menu.

This need may also arise when the user creates a large workflow of different forms calling each other but then wants to close all called forms with one button.

The steps are quite simple:

1) You begin by putting the following code in the WHEN-NEW-FORM-INSTANCE trigger of all the forms in the application


This will create a new global variable called “closing” in your forms system. This value will be false by default and it will be changed to true when the process to exit all has been triggered.

If you do not have a global program unit in your WHEN-NEW-FORM-INSTANCE trigger for all forms, then you will want to use one of the methods to update forms in batch that are available.   You can use either JDAPI or convert all forms to XML and add this code in Notepad++  ( for more information you can checkout Blog posts: JDAPI, Converting Forms to XML)

2) Next step is to check each form when the window is activated if we are in the process of exiting all or if we have reached the main form yet.  Here we want to test

(a) Is the global called “closing” set to true? If so we are in the middle of the exit all process

(b) Have we reached a form called <MAIN_FORM_NAME>. If so we have already arrived to the main navigation form.

To do this we put the following code in WHEN-WINDOW-ACTIVATED trigger of all system forms. Again this maybe done in batch (see above)


:GLOBAL.closing := ‘false’;

We do an exit all without form validation here. This means that if the form has not yet been saved, all changes that were done will be automatically saved. If this is not appropriate for your system then simply replace the  EXIT_FORM(NO_VALIDATE) with EXIT_FORM(NO_VALIDATE,FULL_ROLLBACK) This will be the only way that the forms can close without user intevention. Since if the forms have outstanding changes that require validation it will prompt the users to correct or commit the changes.

Also in the above code don’t forget to replace <MAIN_FORM_NAME> with the name of the main menu or navigation form.

3) The final step in the process is of course how we start the exit all domino effect. This can be done by simply adding an exit all or close all button in the main menu or toolbar.

This button should appear on all forms so anywhere that is seen globally in all forms should be fine.

The code of the button should look like this:

:GLOBAL.closing := ‘true’;


Again you can replace the exit_form command with whats appropriate for your system.

So thats it! As you can see, this is so simple the most time consuming part will be deciding what icon to put on the exit all button. Even here I can help. Checkout the links below. 🙂

Man running for the door

Close all forms

Out the door

Let me know if you have any comments or questions . . . .