Recursive Child Form

Recursive child form, with folders expanded, as seen by an end user
A recursive child form is a child form that will expand with nested grandchild forms infinitely as deeply as the data recurs.

Two examples of recursive child forms in NetForum are the Organization Tree child form on the Individual and Organization profile page. Another example is the sub-committees child form on the Committee profile page, pictured above.

Note that recursive child forms can be slow if you have deeply nested data. For this reason, it is advised to put these child forms on a separate tab to avoid slowing down the form load.

How to Make a Recursive Child Form

recursive child form setup in the Toolkit module

To make a recursive child form, you actually need two child forms. The first child form will show the direct children of the parent record. Next, add a Grandchild Form to this first child form; be sure that you have selected the first child form as the parent child form for your second child form, and be sure to check the is recursive checkbox. In most cases, the child form select sql of the grand-child child form will be identical to that of the parent child form.

The SQL of the child forms will have a WHERE clause linking a primary key up to a parent primary key. Here is the Child Form Select SQL for the sub-committee child form (and grandchild form). Look especially at the WHERE clause on line 6:

  1. SELECT cmt_key,
  2. [Code]=cmt_code,
  3. [Name]=cmt_name,
  4. [Type]=cmt_ctp_code
  5. FROM mb_committee (nolock)
  6. WHERE cmt_parent_key = {cmt_key}
  7. AND cmt_delete_flag=0
  8. ORDER BY 2
  

The recursion comes in because as the grandchild form traverses infinitely downward, each new node "queries up" to its parent node using the cmt_parent_key FK column.