ELSE IF Instruction

The ELSE IF instruction adds a branch to an existing conditional region which HotDocs only processes if the preceding IF condition is false.

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

You can only use an ELSE IF instruction between an IF instruction and an END IF instruction. It must come before any ELSE instructions.

Once you make a region of the template or script conditional using an IF instruction, you can choose to create an alternative region. If the condition in the IF instruction evaluates to false, HotDocs then looks to see if there is an ELSE IF instruction containing an alternative condition. If the condition on the ELSE IF instruction then evaluates to true, HotDocs processes the conditional region directly below the ELSE IF instruction.

You can further modify a conditional region using more ELSE IF instructions or an ELSE instruction, another ELSE IF or ELSE instruction closes the preceding ELSE IF instructions 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:
ELSE IF ELSE IF ⟦EXPRESSION⟧ Replace ⟦EXPRESSION⟧ with a condition that, if the preceding IF condition evaluates to false and this condition evaluate to true during the interview, causes HotDocs to process this conditional region.

Example

For example, in the following script, HotDocs uses an IF instruction to insert a paragraph about 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 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.