Lesson 4: Replace Text and Dates with Variables
Overview
Once you have created a template, the next step in the automation process is to replace text that changes, depending on the user, with variables. Variable fields represent where the user’s information (or answers) will be inserted in the document. Examples of text you’d replace with variables include names, dates, descriptions, numbers, and calculations.
This lesson teaches you how to create and insert Text and Date variables. It also teaches you how to create prompts for variables. Prompts are the questions the user sees when assembling the document.
Start the Tutorial
If you are continuing immediately from Lesson 3, skip the instructions for opening the template and proceed to “Replace the Employee’s Name with a Text Variable.”
If you closed the template at the end of Lesson 3, complete the following steps.
To open the tutorial template
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.
- Open your word processor and click the HotDocs button, located on your word processor’s toolbar. The Test Templates library appears.
- Select Employment Agreement and click Edit. The template appears, ready for you to edit.
Replace the Employee’s Name with a Text Variable
The first instance of text that needs to be replaced in the template is the name of the employee, Tyson Jones, in the first paragraph. You will replace it with a Text variable.
To insert a Text variable
If you are using Word 2007, 2010, and 2013, remember to click the HotDocs tab of the Word ribbon in order to see the HotDocs toolbar.
- Select (highlight) the text Tyson Jones, located in the first paragraph.
- Click the Variable Field button on the HotDocs toolbar. The Variable Field dialog box appears.
- In the Variable type group, make sure Text is selected.
- In the Variable box, type Employee Name.
- Because there are multiple instances of Tyson Jones in the template, click Replace Multiple. A variable component named Employee Name is created and the Find and Replace dialog box appears.
- Make sure the check box labeled Find whole words only is cleared. (Clearing this option allows HotDocs to replace all instances of Tyson Jones with the variable Employee Name, even if a specific instance ends with ’s.)
- Click Replace All. HotDocs replaces all instances of Tyson Jones with «Employee Name».
Replace the Job Title with a Text Variable
The next variable you will replace is the job title (Marketing Manager), which is in the Agreement to Employ and Be Employed section.
To replace the text with a Text variable
- Select the text Marketing Manager.
- Click the Variable Field button. The Variable Field dialog box appears.
- Make sureText is selected in the Variable type group, and type Job Title in the Variable box.
- Since there is only one instance of this variable in the template, click Replace Once. The text is replaced with the variable.
Create Prompts and Adjust the Height of the Answer Field
The next item of text that needs to be replaced is the list of job duties in the Description of Employee’s Duties section.
To replace the list of job duties with a HotDocs variable
An easy way to select or highlight text using the keyboard is to press and hold the Shift key as you press the right or left arrow keys. To select full words at a time, press and hold both Shift and Ctrl as you press the arrow keys.
Before you insert the variable into the template, you can test the variable to see how it will look to the user during the interview.
- Select (highlight) the text overseeing all marketing initiatives for the company and managing a team of writers and designers. (Do not select the period.)
- Click the Variable Field button. The Variable Field dialog box appears.
- Select Text and type Job Description in the Variable box. (Do not click Replace yet.)
To test the variable
You can have HotDocs arrange the template and the test assembly window so that you can view both simultaneously. To do this, resize the test assembly window to the height you want and click the Arrange button in the test assembly window toolbar.
Note that the variable name is used to ask the question the user must answer. In this case, the name does not make a good prompt because it doesn’t help the user’s answer fit into the rest of the sentence. Also, the answer field shows only a single line, which could be a problem for an employee who must list many different job responsibilities.
Clicking Update allows HotDocs to re-display the test assembly window with your changes. However, your changes aren’t saved to the component file until you click OK or Save at the Variable Editor.
- With the Variable Field dialog box still open, click the Edit Component button, next to the variable name. The Text Variable Editor appears.
- Click Test. A test assembly window appears, with the question and answer field showing in the dialog pane.
- With the test assembly window still displayed, place your cursor in the answer field and click the Edit Component button in the assembly window toolbar. The Text Variable Editor comes to the front.
- In the Prompt box, type the following text:
Complete the following sentence: Job duties shall include
- At the Field height box, click the up arrow until the number 4 appears. This will make the answer field four lines high.
- Click Update to view the test assembly window again.
The new prompt appears and the answer field is large enough to hold a longer answer.
- Choose Close (File menu) to close the test assembly window.
- Click OK at the Text Variable Editor, and click Replace Once at the Variable Field dialog box.
Replace Dates with Date Variables
The Employment Agreement template includes several dates that need to be replaced with Date variables. The first date is the agreement date, located in the first paragraph.
To replace the agreement date with a Date variable
The format you assign here will be used for this instance of the variable only. In other words, if you insert this same variable later in the template, it will not have this format assigned. If you want to assign a format that will be used every place the variable is merged, click the Edit Component button at the Variable Field dialog box and select an example format from the Default format drop-down list.
Notice that when you select Date, the Format box in the Merge field properties group shows an example format. This controls the format of an answer when it is merged into a document. It is suggested based on the format of the template text you selected.
In addition to the variable name, the format, third day of June, 1990, is merged into the field as well.
- Select the text sixth day of January, 2009 and click the Variable Field button. The Variable Field dialog box appears.
- In the Variable type group, select Date.
- In the Variable box, type Agreement Date and click Replace Once, since the agreement date appears only once in the document.
On Your Own
The next variable you will replace is the date the employee will start work (February 1, 2009), located at the end of the Agreement to Employ and Be Employed section. Replace the text now with a Date variable named Start Date.
See the previous section for a description of how to do this if you need help.
Use an Unanswered Variable Placeholder
The template includes a date the document will be signed by Hobble Creek Publishing representatives and the employee. Sometimes, however, this information may not be known when the document is assembled.
By default, when users leave questions unanswered, HotDocs displays a warning and then merges a placeholder in the assembled document that indicates the answer is missing. To keep this from happening, you can specify a variable property that instead inserts a blank line so that the date can be entered by hand later. You can also suppress the warning that the variable is unanswered.
You will replace the signature date near the end of the template.
To use an answered variable placeholder
- Scroll to the end of the template.
- Select January 6, 2009 and click the Variable Field button. The Variable Field dialog box appears.
- Select Date and type Signature Date in the Variable box.
- Click the Edit Component button next to the Variable box. The Date Variable Editor appears.
- In the Prompt box, type Signature Date (Leave blank if unknown).
- Click the Advanced tab. The view changes to show advanced properties of the variable.
- Clear Warn when unanswered. This keeps HotDocs from displaying an unanswered warning if the user leaves the answer blank. (This warning would otherwise appear at the end of the interview.)
- Click OK at the Date Variable Editor. You are returned to the Variable Field dialog box.
- Click Show Advanced. The dialog box expands to show advanced options.
- In the Unanswered text box, enter several underline characters, like this: __________.
- Click Hide Advanced to hide the properties again.
- Click Replace Once. The text is replaced with a variable field.
Conclusion
You are now finished with this lesson. In it, you learned how to create Text and Date variables. You also learned how to add a prompt to a variable and change how it looks in the interview. Finally, you learned how to insert a blank line in the document if the user doesn’t answer the question during the interview.
If you do not want to go on to Lesson 5 at this time, click the HotDocs Save and Close button to close the template. Then exit HotDocs.
If you are continuing on to Lesson 5, click the Save button to save your work.