Manage Learn to apply best practices and optimize your operations.

Show or hide a subform from inside a form

This tip describes how to show or hide a form inside a subform.

Ever used a "Computed Subform" in your form to show a chunk of data, and want to change or hide this subform from INSIDE the form (without exiting and reloading the form)?

This tip is useful if you want subforms loaded or not (or different subforms loaded) based, for example, on an environmental variable, and change them on-the-fly with an action bar on the form itself.

Here's how to do it:

  1. Open the form "myForm"
  2. Create a Computed Subform with the formula:
    @If(@Environment("myVar") = "Y" ; "Sub1" ; "Sub2")
  3. Create two Actions with the following formulas, respectively:
    "Show Sub1"
    @Environment("myVar" ; "Y");
    @Command( [ViewSwitchForm] ; "myForm" )
    and "Show Sub2"
    @Environment("myVar" ; "N");
    @Command( [ViewSwitchForm] ; "myForm" )

Now you can open the form "myForm" and click on the two action buttons to switch between the two subforms, or you can substitute "Sub2" with "" in the Computed subfrom formula to toggle between hide/show of Sub1 subform. Be sure to switch to the SAME form (myForm)!

This option for hide/show of chunks of data is much more efficient than having a section with hide-when formulas, because the section is ALWAYS loaded and THEN hidden, while a Computed Subform is NOT loaded if the formula results in a blank string. If Sub1 contains, for example, an embedded view, you can imagine the performance improvement...

Dig Deeper on Domino Resources - Part 7

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...