Lesson 11: Create Scripts for Dialogs
Overview
Some variables you add to a dialog may not need to be asked unless other questions in the dialog are answered a certain way. For example, in the Job Information dialog, you don’t want the employee to enter the number of seminar days unless he or she actually qualifies for them. For situations like this, you can create a dialog script.
To do this, you use a series of instructions that disable certain questions in a dialog based on how other questions are answered. You can either gray or hide variables. Then you use an IF instruction to determine if the variables are relevant to the current user. If they are, you then show or ungray the variables for the user. (In Lesson 8, you learned how to use IF instructions to make text in the template conditional. In this lesson, you will use IF instructions to conditionally enable or disable variables in a dialog.)
Start the Tutorial
If you are continuing immediately from Lesson 10, skip the instructions for opening the template and proceed to “Gray and Ungray Variables in a Script.”
If you closed the template at the end of Lesson 10, complete the following steps.
To open the tutorial template
- Open your word processor and click the HotDocs 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.
- Select Employment Agreement and click Edit. The template appears, ready for you to edit.
- Click the Component Manager button to open Component Manager.
Gray and Ungray Variables in a Script
You will use the GRAY instruction to disable irrelevant variables in a dialog.
To GRAY the Number variable
You can also edit components by double-clicking them in Component Manager.
- At Component Manager, select the Job Information dialog and click Edit Component. The Dialog Editor appears.
- Click the Script tab.
Notice that the Components list shows the variables used in the dialog. This can help you remember the variables with which you are working. The Instruction models list shows you which instructions you can use.
You want to gray the Number of Seminar Days until the user indicates that the employee should receive them.
- Click in the Script box and press Ctrl+Spacebar. The auto-complete list appears.
- Type the letters GR. The GRAY instruction is highlighted.
- Press Enter. The GRAY instruction is inserted.
- Enter a space and then press the F5 key. HotDocs displays a list of just components.
- Select Number of Seminar Days (either press the Down Arrow key to select the component, or start typing the component name) and then press Enter. The variable is inserted in the script.
In the next part of the script, you will define the condition under which the variable will be ungrayed.
To create the instruction to UNGRAY the variable
- Press Enter to start a new line in the script.
- Enter the IF instruction, followed by the variable name Employee to Receive Paid Seminar Days.
- Press Enter.
- On the new line, enter UNGRAY Number of Seminar Days.
- On the next line, enter END IF. Your script should look like this:
Test the Dialog
You can now test your work.
To test the dialog
- At the Dialog Editor, click Test. The test assembly window appears.
- Select Employee to Receive Paid Seminar Days. The Number of Seminar Days answer field becomes enabled.
- Choose Close (File menu) to close the test assembly window.
- Click OK at the Dialog Editor.
Hide and Show Variables in a Dialog
The Salary and Benefits dialog contains two variables—Annual Salary and Hourly Salary. Only one of these variables should be asked during the interview, depending on the employee’s work status. You can use a dialog script to hide these variables and then show only the correct one once the user specifies the status.
To hide variables
- At Component Manager, edit the Salary and Benefits dialog.
- Click the Script tab.
- In the Script box, enter the following script:
HIDE Exempt Annual Salary
HIDE Hourly Salary
Next, you will create the expression that determines which variable is shown.
- Press Enter to start a new line.
- Enter the following lines of script:
IF Employment Status = “Exempt”
SHOW Exempt Annual Salary
Next, you will create the rest of the expression.
- On the next line of the script, enter the following:
ELSE IF Employment Status = "Non-exempt"
OR Employment Status = "Part-time"
SHOW Hourly Salary
END IF
To review, in this script, HotDocs first hides the variables Annual Salary and Hourly Salary. It then determines how the user answered the Employment Status question. If the employee is exempt, the Exempt Annual Salary variable is shown. Or, if the employee is non-exempt or part-time, the Hourly Salary variable is shown.
On Your Own
Once you have added the script to the dialog, you can test it. To do this, click the Test button at the Dialog Editor. Select an employee status and note which variable is asked. Change your answer to see the script update which variable is asked.
When you are finished, close the test assembly window.
Then, close the Dialog Editor.
Finally, close Component Manager by clicking the X in the upper-right corner of Component Manager.
Test Assemble the Template Again
You are now ready to test assemble the template again. You will see how grouping variables into dialogs makes the interview process easier for users.
To test assemble the template
- At the template, click the Test Assemble button. The test assembly window appears.
- Answer the questions in the interview, pressing Tab to move between answer fields and clicking Next (or Page Down) to move between dialogs.
- Continue answering questions as dialogs appear.
- After you reach the End of Interview dialog, click the Document Preview tab to preview the assembled document.
- Close the test assembly window.
- At the template, click the Save and Close button. The template is saved and closed.
Congratulations! You have completed automation work on the Employment Agreement template. In the next few lessons, you will continue to learn new automation concepts as you work in different templates.
Conclusion
You are now finished with this lesson. In it, you learned how to use dialog scripts to dynamically ask or disable variables in a dialog, based on how the user answers other questions in the dialog.
If you do not want to go on to Lesson 12 at this time, exit HotDocs.