Manage Learn to apply best practices and optimize your operations.

Insert A Subform Dynamically

Have you ever encountered the problem like: you have one form and several
subforms, you want to insert only one of the computed subform to the form
depending on the user's selection, instead of putting all the subforms into the
form and controlling the hide-when formula to show the subform. Maybe you can
try this.
1. Let's say if we have one form called "main", and three subform named

2. Now, we're going to define which subform should be inserted to the form when
user select. We create another form and name it "link", which has two text
fields: "Option" and "SubformName".
Based on this form, create three documents: Input "option1" and "sub1" (the
subform's name) in the first document, "option2" and "sub2" in the second and
"option3" and "sub3" into the third document.

3. Create a view, name it "subformview", use "Option" field as the first SORTED
column, "Subform" field as the second column (you can hide this column). View
selection fomula:
SELECT Form = "link"

4. Create a view action button called "New Doc":
ENVIRONMENT choosesubform:[email protected]([Custom] ; "":"" ; "subformView" ; "Select
an option" ; "Please select one from the pick list:" ;1);
@Command([Compose]; ""; "main")

5. Open the "main" form in Design mode, create a computed text field named
"selectedoption", write a value formula in this computed field:

Then click where you want to paste the subform, create-insert subform select
"Insert Subform based on formula". Enter the formula that determines which
subform to display.

save the form.
Press "New Doc" button from the view and see you can choose which subform you
want to insert.

Hope this helps

Dig Deeper on Domino Resources - Part 5

  • Favorite iSeries cheat sheets

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