top of page

105. Internal Database Tables - An Alternative to Pick Lists

Description

How to emulate a database table without using pick lists or external databases; how to select multiple records on a single dialog; how to associate two or more different lists with a particular dialog.

Code

Explanation

HotDocs provides pick lists to allow users to select data from data records on dialogs. However, HotDocs permits only one pick list to be associated with a particular dialog and does not permit multiple records to be selected for one dialog. (Note: pick lists do permit you to select multiple records for spreadsheet-style repeating dialogs, but you cannot select multiple records on a particular repeat iteration. For example, you can select John as trustee at the first repetition, Helen at the second repetition, and so on, but you can't select John and Helen as co-trustees on one repetition.)

The following discussion presents a strategy for creating a system independent of pick lists that overcomes these limitations. The discussion assumes some familiarity with database terminology. HotDocs Pro 5.x is required.

To break the problem down into three parts:

1. Aside from pick lists and external databases, how can we store data in a database table format in HotDocs?
2. How can we allow users to select records from more than one list on a single dialog?
3. How do we extract data fields from the table and insert them in the template based on the user's selections?

First, we figure out our table structure; in other words, what are the field names and variable types for each field. This will serve as a guide when we create variables for the dialogs used to collect the data that will then be added to the table.

The object is to create a master repeating dialog (never displayed to the user), which we will call "Data Table," containing all of the data table field variables we require. The variables could have generic names like:

• FirstName-t
• MiddleName-t
• LastName-t
• Suffix-t
• FullName-t (computed from first, middle, last, suffix)
• Gender-m
• DateOfBirth-d
• etc.
(Under Advanced Options for these variables, it's a good idea to check "Ask Only in Dialog" and "Don't Warn If Unanswered.")

We will also create an index number field (Index-n) to identify each record, and a numeric counter variable (DataTableCounter-n) that we can use to assign and keep track of the sequential index numbers.

For each dialog we create to collect personal data, we will create a corresponding computation to add the data to the master table. For example:

REPEAT Client's Children
SET DataTableCounter-n TO DataTableCounter-n + 1
SET Index-n[DataTableCounter-n] TO DataTableCounter-n
SET FirstName-t[DataTableCounter-n] TO ChildFirstName-t
SET MiddleName-t[DataTableCounter-n] TO ChildMiddleName-t
... etc.
END REPEAT
Note here that although the data table field variables are not actually on the "Client's Children" dialog, HotDocs allows you to copy values to "Data Table" field variables, effectively creating a "Data Table" on the fly.

As an alternative to collecting data through a series of separate dialogs, we could also present the user with one master "names interview" at the beginning of assembly. Using this method, the user is prompted to input all information about every person needed in the documents without respect to the person's role. This information is placed into the "Data Table" dialog using the same type of computation as above.

That takes care of constructing Data Table; now how do we allow the user to select more than one record on a dialog? For each selection to be made, we need to generate a multiple choice variable where the options consist of the index number followed by names taken from our Data Table:

ASK NONE
REPEAT Data Table
ASCEND LastName-t //to sort the list by last name
SET Temp-t TO FORMAT( Index-n, "09" ) + " " + FullName-t
ADD Temp-t TO SuccessorTrustee1-m
ADD Temp-t TO SuccessorTrustee2-m
ADD Temp-t TO meSuccessorTrustee3
... etc.
END REPEAT
ASK DEFAULT
(Note: The ASK commands prevent the data table from popping up during assembly.) So the mc options might look like this:

11 John Adams
06 Susan Adams
08 Larry Boone
Formatting the index number as "09" (which produces 01, 02, etc.) allows the names to line up properly, and moreover when we need to pull the index number out later we can simply grab the first two characters. (Note: if you anticipate your list may exceed 99 items, you should format your numbers as "009".)

Note also that it would be easy to filter the data table to create lists that are more specific.

These mc variables can then be placed on repeating or regular dialogs to allow the user to make selections (dropdown lists work handily and save space on the dialog). You can put as many of the mc variables on a dialog as you want, which solves the pick list limitation of one per dialog. Bear in mind, however, that whereas pick lists allow users to add data records at the same time as they are making selections, you would not be able to do that here - all the data pertaining to the selections for a particular dialog must be collected before the choices are presented to the user.

After the user makes selections, we extract the index numbers like this:

REPEAT Successor Trustees
SET SuccessorTrustee1-n TO FIRST( SuccessorTrustee1-m, 2 )
SET SuccessorTrustee2-n TO FIRST( SuccessorTrustee2-m, 2 )
SET SuccessorTrustee3-n TO FIRST( SuccessorTrustee3-m, 2 )
END REPEAT
where SuccessorTrustee1-n is a number variable the purpose of which is to hold the index number of the name selected (conveniently, HotDocs converts an mc text value such as "01" to the numeric value "1"). The number variables must be placed on the dialogs also, but since we want the user to see the mc variables only, we can use dialog script commands to HIDE the number variables.

Finally, to allow the template to access the various "data fields" according to the user's selections, we insert variables into the template in the following format:

"If for any reason any one of «FullName-t[SuccessorTrustee1-n]:LIKE THIS», «FullName-t[SuccessorTrustee2-n]:LIKE THIS» and «FullName-t[SuccessorTrustee3-n]:LIKE THIS» fails or ceases to act, ... "
This may look a little strange, but what's happening is that the user's mc selection provides an index number that hooks into the master data table, which in turn allows us to access an unlimited number of data field values for that person (not to mention the fact that we don't have to create a proliferation of data variables). For example, we can use any of the following variables:

«Gender-m[SuccessorTrustee1-n]:he/she»
«DateOfBirth-d[SuccessorTrustee1-n]:June 3, 1990»
«CountyOfResidence-t[SuccessorTrustee1-n]»
etc.
Note: While HotDocs has no trouble interpreting «VarName[Index]», unfortunately it provides no easy method of inserting variables of that form into templates. However, you could use the computation creation dialog box as a scratch pad to create the variable using HotDocs' drag and drop features, and then cut and paste the result into the template. (Note that typing "<<" or ">>" in the computation editor automatically produces the appropriate chevron.) If you wish you may color the text between the chevrons blue, but this step is optional, and if you do you should not color the chevrons themselves (doing so will leave the color behind after assembly).

IMPORTANT: Be aware that if you revamp an existing system according to this schema, you should have a strategy for converting values from previous answer files to the new system so that no information will be lost.

©2023 by My Site. Proudly created with Wix.com

  • Facebook
  • Twitter
  • LinkedIn
bottom of page