Lesson 8: Make Paragraphs Conditional

Overview

Sometimes your templates contain optional text, or text that should be included only when certain conditions are met. To include or exclude optional text, you can create an IF instruction. An IF instruction uses a True/False variable or some other test that produces a true/false value to include or exclude text in the assembled docu­ment.

The employment agreement template contains several paragraphs that are optional. You will learn how to include or exclude single paragraphs of text using simple True/False variables. You will also learn how to include or exclude alternate versions of a single paragraph by creating a series of IF/ELSE IF expressions.

Start the Tutorial

If you are continuing immediately from Lesson 7, skip the instructions for opening the template and proceed to “Conditionally Insert a Single Paragraph of Text.”

If you closed the template at the end of Lesson 7, complete the following steps.

To open the tutorial template

  1. Open your word processor and click the hotdocs00224.jpgHotDocs button, located on your word processor’s toolbar. The My Test Templates library appears.

    If the My Test Templates library does not appear, choose Open Library (File menu), select the library in the default Libraries folder (for example, My Test Templates.hdl), and click Open.

  2. Select Employment Agreement and click edittemplate00227.jpgEdit. The template appears, ready for you to edit.

Conditionally Insert a Single Paragraph of Text

The employment agreement template contains a paragraph describing a probation period an employee must complete before being officially hired. It also contains a paragraph about the new employee’s privilege of attending training seminars throughout the year. However, not all Hobble Creek Publishing employees receive paid seminar days, nor are all new employees required to complete a trial period. In this template, you can make these paragraphs conditional, meaning they will be included in the finished document only when this information applies to the new employee.

To make text conditional, you use an IF instruction, which works by testing to see if one or more conditions are true. If so, the IF instruction merges the conditional text into the document.

The simplest way to create an IF instruction is to use a True/False variable, which asks a yes/no question. In this case, if the answer to the question is yes, the text will be merged into the document.

To create an IF instruction

inset_8700454.png

By default, when inserting instructions in a template, HotDocs inserts a return after the instruction. Then, during assembly, as the instruction is processed and removed from the assembled document, HotDocs removes the return it inserted as well.

  1. Select the first paragraph in the Duration of Employment section:

    if-word-selected.jpg

    if-wordperfect-selected.jpg

    • If you are using Word, make sure you select the paragraph mark. (You may need to click the Show/Hide ¶ button in Word if you need help identifying the paragraph mark.) The selected text should look like this:
    • If you are using WordPerfect, select the blank line after the paragraph, too. The selected text should look like this:
  2. Click the if00451.jpgIF Field button. The IF Field dialog box appears.
  3. Make sure IF True/False Variable is selected and type Employee to Complete Trial Period in the True/False variable box.
  4. Click OK. The paragraph is now surrounded by an IF instruction.

On Your Own

In the Time Away From Work section of the template, make the last paragraph (starting with “Additionally, «Employee Name» shall be allowed...”) conditional. Name the True/False variable Employee to Receive Paid Seminar Days. Remember to select the entire paragraph (including the paragraph mark) before creating the instruction.

Please refer to the previous section if you do not remember how to do this.

When the instruction is merged in the template, the END IF instruction takes on the formatting properties of the heading immediately following it. This is OK.

std-select-compensation-wordperfect.jpg

std-if-expression.jpg

std-variable-editor-employee-status-1.jpg

The options available in the Style drop-down control how the options are pre­sented in the dialog.

std-variable-editor-employee-status-2.jpg

std-if-expression-employee-status-1.jpg

std-if-expression-employee-status-2.jpg

std-if-expression-employee-status-3.jpg

std-if-expression-employee-status-4.jpg

Conditionally Insert Alternate Paragraphs of Text

In addition to using an instruction or expression to merge or remove a single block of text, there may be times when you have multiple versions of a paragraph, only one version of which should be merged into the assembled document. To accom­plish 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 the Compensation and Reimbursement section of the Employment Agreement, the first three paragraphs describe the compensation rate for the employee. Which compensation rate the employee receives depends on the employee’s work status—full-time, non-exempt; full-time, exempt; or part-time.

HotDocs processes IF instructions by starting at the top of the IF instruction and looking for the first con­dition 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 instruc­tion.) If the condition that controls the IF instruction is not answered, none of the instructions are processed and no text is merged in the document.

In this part of the lesson, you will make each of these paragraphs conditional. You will base the condition on the user’s answer to a Multiple Choice variable that defines the work status.

Create the Variable Used in the Conditional Test

In this template, you want the first of these alternate paragraphs merged into the document only when the employee’s status is full-time, exempt. To determine this, you must first create a Multiple Choice variable, which will be used in the condi­tional test.

To create the Multiple Choice variable

if-wordperfect-compensation-selected.jpg

inset_8800502.png

inset_8900506.png

inset_9100508.png

  1. Select the first paragraph in the Compensation and Reimbursement section.

    This is how it should look in Word. (Make sure you select the entire paragraph, including the paragraph mark.)

    if-word-compensation-selected.jpg

    In WordPerfect, select the blank line after the paragraph as well. This is how it should look:

  2. Click the if00499.jpgIF Field button. The IF Field dialog box appears.
  3. Select IF Expression. The view changes to show a scripting box.
  4. Click the newcomponent00503.jpgNew Component button. The New Component dialog box appears.
  5. Select Multiple Choice Variable and click OK. The Multiple Choice Variable Editor appears.
  6. Type Employment Status in the Variable name box.
  7. Type Exempt in the first row of the Option column.
  8. Type Non-exempt and Part-time, respectively, in the second and third rows.

    inset_9000507.png

    The options available in the Style drop-down control how the options are pre­sented in the dialog.

  9. Click the Style drop-down button and choose Button Grid.
  10. Click OK. You are returned to the IF Field dialog box.

Create the First Expression

Now that you have created the variable on which you will base the condition, you can create the expression script that determines whether the paragraph you have selected will be included in the document.

In Lesson 7, you learned how you can drag expression and instruction models to the scripting box to create a script. Another way you can write a script is by typing it directly in the script box. When doing this, you can press certain keystroke combi­nations that display auto-complete lists of expression and instruction keywords as well as components. You can then choose an option and it will be inserted in the script.

To create the IF expression

inset_9200509.png

inset_9300510.png

inset_9400511.png

inset_9500512.png

inset_9600513.png

inset_9700514.png

  1. Place your cursor in the Expression box and press both the Ctrl key and the Spacebar simultaneously. HotDocs displays the auto-complete list.
  2. Type the letters empl. HotDocs begins limiting the list of options to include only those components that contain these characters.
  3. Press the DOWN ARROW key to select Employment Status and press Enter. The component name is merged in the Expression box.
  4. Press the Spacebar and then type an equal sign (=) followed by another space.
  5. Press Ctrl+Spacebar again. This displays a list of all the options available for the Employment Status variable.
  6. Using the DOWN ARROW key, select Exempt and press Enter. The option, which is enclosed in quotation marks, is merged in the script.
  7. Click OK. The paragraph is surrounded by the instruction.

    To review, this expression merges the paragraph in the assembled document only if the user selects Exempt as his or her employment status.

Create an ELSE IF Instruction

You will now create the condition that will merge the paragraph for non-exempt employees.

To create the ELSE IF instruction

inset_9800522.png

Employment Status = "Non-exempt"

  1. Select (highlight) the END IF instruction at the end of the first condition as well as the entire second paragraph, like this:

    if-word-second-paragraph-selected.jpg

    In WordPerfect, it should look like this:

  2. Click the if00519.jpgIF Field button. The ELSE Field dialog box appears.
  3. Select ELSE IF Expression. The view changes to show the scripting box again.
  4. Enter the following script. (Remember, you can press Ctrl+Spacebar to access the list of scripting options.)
  5. When you are finished, click OK. The ELSE IF instruction is merged in the template.

    If the employee’s employment status is non-exempt, this paragraph will be merged in the assembled document.

On Your Own

Make the paragraph for part-time employees conditional. Remember to select the END IF instruction from the previous paragraph as you select the paragraph. The ELSE IF expression should contain the following script:

Employment Status = "Part-time"

In this final IF expression, if the employee’s status is part-time, the paragraph describing the part-time salary will be merged in the assembled document.

Conclusion

You are now finished with this lesson. In it, you learned how to make single para­graphs conditional using a True/False variable. You then learned how to make alter­nate paragraphs conditional using ELSE IF expressions.

At this point in the tutorial, you have added all of the variables and instructions to the template that are required to produce an assembled document. In the next lesson, you will test your work.

If you do not want to go on to Lesson 9 at this time, click the HotDocs close00311.jpgSave and Close button to close the template. Then exit HotDocs.

If you are continuing on to Lesson 9, click the save00314.jpgSave button to save your work.