HotDocs Models: if expression; elseIf; else; endIf

Placeholder Replace With
expression A statement that can be evaluated as true or false

You can make sections of a HotDocs Model conditional by using if instructions. You can also make instructions or expressions in a script conditional. A conditional section will be included only if a condition you specify is true. The elseIf instruction allows two or more conditions to be included in an if instruction. The else instruction establishes a final condition for an if instruction, specifying that if all preceding conditions are false, the following information should be included. It must be the last item of the if instruction.

Each if instruction or expression must end with an endIf instruction. This instruction completes a section of conditional logic. These pairs can be nested, allowing you to test several conditions before applying a single effect.

If you are inserting an if field directly in a HotDocs Model, the endIf field is represented by a closing bracket (]). See Mark Conditional Text for details.

In the following example, HotDocs uses an if instruction to insert a paragraph about vacation time—but only if the new employee qualifies for paid vacation:

[if:VacationDays:In addition, [EmployeeName;te] shall be allowed [NumberOfVacationDays;nu;format=alpha] for vacation time. [EmployeeName;te] shall also receive seven paid holidays, including New Year's Day, Memorial Day, Fourth of July, Labor Day, Thanksgiving (including the day after), and Christmas.

]

More complex situations can also be handled using if expressions. For example, in the following computation script, a single paragraph may change depending on how close a project is to completion. Using the if, elseIf, and else instructions, the correct paragraph can be inserted:

if ProjectStatus = "Complete"

"Upon finishing the project…"

elseIf ProjectStatus = "In Process"

"While working on the project…"

else

"Before working on the project…"

endIf

You can use if expressions anywhere. Operators such as and and or can link multiple conditions, giving the user greater control over the interview. However, creating complicated if instructions directly in the model can make the assembly process sluggish. Consider using Computation variables or insert instructions instead.

For more information about using conditional expressions in your model, see Mark Conditional Text.