Include or Exclude Multiple Versions of Text Using IF and ELSE IF Instructions or Expressions

Often you have a simple paragraph (or other section) of 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. (See Include or Exclude a Single Version of Text Using a Simple IF Instruction or Expression.)

In other cases, however, you may have multiple versions of text, only one version of which you want to include in the document. You can condition each section using a series of ELSE IF and ELSE instructions. For example, if you have different versions of a paragraph you use for different field offices, you can use the ELSE IF and ELSE expressions to insert the correct paragraph, based on a user's answers. You can use both ELSE IF and ELSE in the same IF instruction, but ELSE must always be the last item in the instruction.

In the following example, the first part of the condition tests whether the client lives in the state of Idaho. If so, the paragraph for Idaho sales tax is merged. If the client doesn't live in Idaho but does live in Utah, the paragraph about Utah sales tax is merged. Finally, if the client lives in a state other than Idaho or Utah, the paragraph keeping them from paying sales tax is merged.

«IF Client Lives in Idaho»

Sales tax for the State of Idaho is «Sales Tax Amount»% and must be paid at the time of purchase.

«ELSE IF Client Lives in Utah» Sales tax for the State of Utah is «Sales Tax Amount»% and must be paid at the time of purchase.

«ELSE» No sales tax must be paid.

«END IF»

To create these ELSE IF sections, you can use either True/False variables or you can use expressions.

HotDocs processes IF instructions by starting at the top of the IF instruction and looking for the first condition that is true. Once it finds a true condition, it inserts the correct text and continues processing any additional instructions. But if all the conditions are false, HotDocs doesn’t insert anything at all (unless there is an ELSE instruction.) When the True/False variable that controls the IF instruction is not answered, none of the instructions are processed and no text is merged in the document.

To add or exclude multiple versions of text using two or more True/False variables or expressions

  1. Highlight the first conditional part of the template and create an IF instruction. (See Include or Exclude a Single Version of Text Using a Simple IF Instruction or Expression.)
  2. Select the IF instruction’s END IF keywords together with the next section of conditional text and click the IF Field button. The ELSE Field dialog box appears.
  3. Select ELSE IF True/False Variable or ELSE IF Expression. The dialog box changes to show the options for defining the condition.
  4. Enter a name in the True/False variable field, or enter an expression in the Expression field.
  5. Click OK to complete the instruction.
  6. Repeat this procedure for each section of conditional text, making sure you select the preceding section’s END IF instruction, along with the new section of text.

Optionally, if you have a paragraph or block of text you want to include if all other conditions are false, you can use an ELSE instruction.

  1. Highlight the last END IF instruction together with the part of the template you want to be used if none of the preceding conditions in the instruction are true.
  2. Click the IF Field button. The ELSE Field dialog box opens.
  3. Select ELSE and click OK. The selected section of the text is added to the IF instruction. (You don't have to specify a condition for this section—it will simply be used whenever all the earlier conditions are false.)

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

When the conditions in an ELSE IF instruction are all True/False variables, you can put them together in a single-selection group in a dialog. (See Change a Dialog's Options.)

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.)