Include or Exclude a Single Version of Text Using a Simple IF Instruction or Expression

Often you have text in your template that you want to include or exclude based either on users' answers or on other conditions being met during the interview. For example, perhaps you need to include a client's shipping address. You can use a True/False variable to determine whether the shipping address is different from the billing address. If so, the Shipping variables will be asked and their answers will be merged into the assembled document. If not, only the Billing variables will be asked and merged.

Sometimes the situation in which you want to merge the text requires a little more information. In this case, you can use a True/False expression to condition the text. For example, perhaps you need to include a list of minor children in the document; however, you only want this list to appear if the client is married and if the children are under the age of 18. To accomplish this, you can create a True/False expression. Like a True/False variable, an expression must result in either true or false for the text to be merged or excluded correctly. Expressions are often used when a simple True/False variable doesn't convey the condition you need.

In some templates, you may have multiple versions of text, only one of which you want to include in the document. You can condition each section using a series of ELSE IF and ELSE expressions. The process of creating these expressions is similar to creating them for True/False variables. To understand how to do this, see Include or Exclude Multiple Versions of Text Using IF and ELSE IF Instructions or Expressions.

A true expression produces a true/false value. For example, the expression YEARS FROM( Child’s Birth Date, TODAY ) produces a number (the age of a person), not a true or false value—it is not a True/False expression. But the expression YEARS FROM( Child’s Birth Date, TODAY ) <= 17 can only result in true or false. It is a True/False expression.

By default, when HotDocs inserts an IF expression in the template, it includes a return character after the instruction. During assembly, as the instruction is processed and removed from the assembled document, this return character is likewise removed. If you would prefer to keep this character from being merged entirely, or if you want to merge a return character only when working with complete paragraphs of text, you can specify an option that controls this. See Control When Returns Are Inserted After Instructions in Text Templates and Understand How Smart Returns are Inserted After Instructions.

To condition text using a True/False variable

  1. Highlight the template text you want to make conditional—a word, a sentence, a paragraph, an instruction, and so forth.
  2. Click the IF Field button. The IF Field dialog box appears.
  3. Select IF True/False Variable.
  4. Type a name in the True/False variable field, or select an existing variable from the drop-down list.
  5. Optionally, click the Edit Component button to make changes to the variable's component properties. (See Customize a True/False Variable.)
  6. Click OK. HotDocs inserts an IF instruction around the text you selected.

To add or exclude text based on a True/False expression

  1. Select the text in the template you want to make conditional—a word, a sentence, a paragraph, an instruction, and so forth.
  2. Click the IF Field button. The IF Field dialog box appears.
  3. Select IF Expression. The window changes to let you create a script for the expression. (See Understand the HotDocs Scripting Language.)
  4. Enter the script, using models from the Expression models list. (For example, the following is an expression that tests three different conditions: 1) the client must be married, 2) the client must be over age 25, and 3) the client must live in Pennsylvania: Client is Married AND AGE( Client Birth Date ) > 25 AND Client State= "Pennsylvania".)
  5. Click OK. HotDocs inserts the expression around the part of the template you selected.

True/false expressions can contain only 512 characters. If longer, you must use a Computation variable.

When the True/False variable appears during the interview, the variable name is used as the prompt. You can enter a Prompt at the True/False Variable Editor to make it more specific. (See Tips on Naming Your Variables and Create a Prompt for a Variable.) Additionally, you can include a resource (see Add Resource Information to a Variable or Dialog.)

To help you create the expression, you can use predefined expression models from a list of models. Two expression models you will use frequently are MULT_CHOICE = TEXT and MULT_CHOICE != TEXT—both of which test what the answer is for a Multiple Choice variable.

You cannot use an IF instruction to condition a table that appears within another table. For example, if you have a table which contains another table within one of its cells, you cannot use a condition to remove the embedded table during assembly. (If you do, HotDocs only removes the text from the table and leaves the empty table in the assembled document.)