Repeat a Form Template

From HotDocs Wiki

Jump to: navigation, search

Using HotDocs Automator, you can repeat forms and populate them with different data by using a series of filters, SET instructions, and conditional computations. This is useful if you have a list of entries that must appear on separate pages.

Repeating a form template requires two separate templates. The first template, referred to as the Main Template below, is added to the library and selected when the user wants to assemble a form document. It contains variable fields for the first set of information or repetition of the form template. The second template, the Secondary Template, is basically a copy of the first template and it is appended to the end of the first template for each subsequent repetition of the form.

To repeat a form template, you must complete the following four parts:

Contents

Part 1: To create and automate the main template

Repeat Dialog This repeated dialog contains the variables that appear on each page of the repeated form. Because it is used in both templates, it must be in each template's component file.
Filter Var 1 This Computation variable is used in the Main Template to separate each repetition of Repeat Dialog to be presented on a new page. This also ensures that HotDocs doesn't automatically send the information to an addendum.
  1. Create the initial template, Main Template, as well as its fields, variables, and dialogs.
  2. Make sure the dialog containing answers to be repeated in subsequent forms, Repeat Dialog, is assigned the Repeated Series or Spreadsheet style.
  3. Select the fields for the variables included in Repeat Dialog, then click Group as Table (Field menu).
  4. Double-click the grouped fields. The REPEAT Field dialog box appears.
  5. Select Repeat Dialog (where Repeat Dialog is the name of your repeated dialog) from the Dialog drop-down list.
  6. Click the Edit Component button next to the Filter by drop-down list. (If the Filter by drop-down list is not visible, click Show Advanced.) The Computation Editor appears.
  7. In the Variable name box, enter a name for the filter, such as Filter Var 1.
  8. In the Script box, enter the following script, where 1 is the number of repetitions of the repeated dialog that can fit on each page of the form:
    COUNTER <= 1
Note: This filter ensures that HotDocs merges only the number of answers that fit on the form, thus avoiding sending additional answers to the addendum.

Part 2: To create and initialize the temporary Number

Set Num Var This Computation variable is used in the Main Template to set the initial value of the Num Var variable.
Num Var This Number variable is used in both templates as a way to track how many times to insert the Secondary Template.
  1. At the top of the initial template, Main Template, create a new control field. (At the Field Properties dialog box for the field, select Control.)
  2. With the control field selected, click the Variable Field button. The Variable Field dialog box appears.
  3. Create a Computation variable named Set Num Var, then click the Edit Component button. The Computation Editor appears.
  4. Click the New Component button. The New Component dialog box appears.
  5. Create a temporary Number variable named Num Var.
  6. At the Script box, enter the following script:
    SET Num Var TO 1
  7. At the HotDocs Automator window, click the Save button to save your changes to the template.

Part 3: To create and automate the secondary (inserted) template

Repeat Dialog This repeated dialog contains the variables that appear on each page of the repeated form. Because it is used in both templates, it must be in each template's component file.
Num Var This Number variable is used in both templates as a way to track how many times to insert the Secondary Template.
Filter Var 1 This Computation variable is used in the Main Template to separate each repetition of Repeat Dialog to be presented on a new page. This also ensures that HotDocs doesn't automatically send the information to an addendum.
Filter Var 2 This Computation variable is used in the Secondary Template to control when the fields are processed.
  1. With the main template open in HotDocs Automator, select Save As (File menu). The Save As dialog box appears.
  2. Enter Secondary Template in the File name box, then click Save. HotDocs creates a copy of the main template and component file and displays it in the HotDocs Automator window.
  3. Delete the Set Num Var control field at the top of the Secondary Template. (The temporary Number variable should only be initialized to 1 at the beginning of the Main Template.)
  4. Double-click the grouped fields containing variables from Repeat Dialog. The REPEAT Field dialog box appears.
  5. Replace the existing filter Computation variable (Filter Var 1) with a new Computation variable named Filter Var 2. The script for this new computation is as follows:
    COUNTER = Num Var

Part 4: To create computations to repeatedly insert the secondary template

Repeat Dialog This repeated dialog contains the variables that appear on each page of the repeated form. Because it is used in both templates, it must be in each template's component file.
Num Var This Number variable is used in both templates as a way to track how many times to insert the Secondary Template.
Additional Page This Computation variable is used in the Main Template and Secondary Template to control when the Secondary Template is inserted.
  1. At the bottom of Secondary Template, create a new control field. (At the Field Properties dialog box for the field, select Control.)
  2. With the control field selected, click the Variable Field button. The Variable Field dialog box appears.
  3. Create a Computation variable named Additional Page, and enter the following script in the Script box:
    IF COUNT( Repeat Dialog ) > Num Var 
      SET Num Var TO  Num Var + 1  
      INSERT "Secondary Template.hft"  
    END IF
    Note: HotDocs 6.2 users: You can use INCREMENT Num Var instead of SET Num Var TO Num Var + 1 in this computation script.
  4. Repeat steps 1–3 to create an identical control field and computation at the bottom of the Main Template. (You can copy the Computation variable from the Secondary Template component file to the Main Template component file using Component Manager.)