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
- END IF IF Field ELSE Field
- ELSE IF True/False Variable ELSE IF Expression
- True/False variable Expression
- OK
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.
- END IF
- Click the IF Field ELSE Field
- Select ELSE OK
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.)