Introduction: Make Parts of Templates Conditional

Sometimes your templates contain optional text, or text that should be included only when certain conditions are met. To include or exclude text based on these conditions, either you create an IF instruction, which is based on a True/False variable, or you create an IF expression, which is based on other conditional tests. In either situation, the IF instruction or expression must result in a true/false (or yes/no) result.

For example, in an estate planning document, there may be a paragraph that lists children who stand to inherit part of the client's estate. However, if the client doesn't have children, this paragraph should not be included. To keep it from being merged in cases where it's not relevant to the client, you can condition the paragraph on a True/False variable that determines whether the client has children. If a simple True/False variable doesn't accomplish what you need, you can create a more complicated expression. Types of expressions include testing against which option of a Multiple Choice variable was selected, whether the value of an answer is equal to (or greater than or less than) another value, and so forth.

In this example, the sentence that begins "Premium rate adjustments due to change..." will be merged into the document only if the true/false variable Step Rate Tables is TRUE.

Also, the sentence beginning "Rates will be guaranteed..." and containing the computation variable Rate Guarantee Calculation will be merged into the document only when the answer to the variable Rate Guarantee is either 2 years or 3 years. If this condition is not met, Rate Guarantee Calculation will not be run.

In addition to using a single instruction or expression to merge or remove a single block of text, there may be times when you have multiple versions of a paragraph or other text, only one version of which should be merged into the assembled document. To accomplish this, you can use a series of ELSE IF instructions or expressions. If you have a paragraph that should be merged when no conditions are met, you can use an ELSE instruction.

In past versions of HotDocs, using END by itself instead of the complete END IF instruction was sufficient. Beginning with 11.1, HotDocs no longer processes the shortened version, and now requires the complete instruction.