Including HotDocs Scripting In a HotDocs Model

As you mark up your HotDocs Models, you may need create scripts that perform a particular task, such as insert one model into another or perform some action based on an answer the user provides. Similarly, you may need to add up several dollar amounts, or find the number of years between two given dates. Or, you may need to search a user’s answer for a certain string of text.

To accomplish this, you must use the HotDocs scripting language, which consists of instructions, expressions, operators, and values—such as text, numbers, dates, or answers users enter. You can include scripts in your markup to help you accomplish these different tasks.

Specifically, an instruction tells HotDocs to perform some sort of function, while an expression retrieves a special value. Most instructions and expressions also include placeholders, which you must replace with a value. Possible values include text strings, number amounts, other expressions, or variables. An instruction or expression will not work until all of its placeholders are replaced.

In addition to using instructions and expressions, you can use operators to control how a script is processed. Most operators are common mathematical signs, but there are also Boolean operators such as; AND and OR, as well as comparison operators.

When creating scripts, instruction and expression keywords can either be entered in the Script column of a Computation Variables table, or as an in-line property of a computation field. Keyword names are not case sensitive, but it is recommended you enter them in lowercase. Multi-word keywords are entered as one word, capitalizing the second (and any remaining) words in the expression or instruction. For example, to determine the absolute value of a number, you would enter the keyword as absoluteValue.

Template developers automating templates in HotDocs are required to use all uppercase letters when using scripting keywords. To accommodate this difference between template development and creating HotDocs Models, you can specify a setting in the HotDocs Model that allows for uppercase letters in expression and instruction keywords. See Define Settings for a HotDocs Model.