IF Instruction

The IF instruction creates the start of a conditional region.

The IF instruction is available when you are creating a script in the Component Studio or from the Field Editor in a template.

You must use an END IF instruction after an IF instruction to close the conditional region.

You can make a region of a template or script conditional by surrounding it with an IF and END IF instruction. In the IF instruction, you must set a condition using an expression or a True/False variable. If that condition evaluates to True during the interview, HotDocs processes the conditional region directly below the IF instruction.

You can modify a conditional region using ELSE IF and ELSE instructions (ELSE IF or ELSE instructions close the IF instruction's conditional region in the same way as an END IF instruction).

You can use operators (such as AND and OR) to link multiple conditions in one expression.

Instruction name Model After you drag and drop the model into the script tab:
IF IF EXPRESSION Replace ⟦EXPRESSION⟧ with a condition that, if it evaluate to true during the interview, causes HotDocs to process this conditional region.

Example

For example, a template could contain an IF instruction telling HotDocs to insert a paragraph about paid vacation time—but only if the new employee qualifies for paid vacation:

[IF Vacation Days]In addition, [Employee Name] shall be allowed [Number of Vacation Days:ten] for vacation time.

[Employee Name] 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.[END IF]

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

IF Project Status = "Complete"

"Upon finishing the project..."

ELSE IF Project Status = "In Process"

 "While working on the project…"

ELSE

       "Before working on the project..."

END IF

Download

After you download the example template, you can import the template to any workspace to see this example code in action.