HotDocs Author WorkflowCreate a template Add placeholders Group variables in dialogs Upload a template Create a script

Functions Overview

A function is a named calculation in the HotDocs scripting language that takes zero or more values as inputs (parameters) and produces a single value as a result; the HotDocs scripting language includes system functions, but also enables you to create your own. For example, you can use the YEARS FROM function to calculate the number of years between two date values as a means to calculating the length of a mortgage.


Functions (like instructions) tell HotDocs to accomplish a task. The difference is that the task a function tells HotDocs to do, is to calculate a value of a given type. An instruction does not return a value. You can use a function alone or with other functions, variables and operators when crafting an expression in a HotDocs script.

There are two kinds of functions in the HotDocs scripting language:

As mentioned above, functions (whether system or custom) typically take one or more values as input, and produce a single value as a result. In practice, you refer to the value represented by a function, using the function’s name. This use of a function name (in the context where you want its value) is known as a function “call”. You call the function to request its value, and the function executes, evaluating the contents of the input with it own internal commands to calculate a result. You can then use that result within another function, or provide that result as the finished value that HotDocs uses to replace a placeholder field when assembling a document.

Common Tasks

Among others, functions enable you to perform the following common tasks:


When you write a script, you can add a function to the script in one of two ways: either you drag and drop a model from the Models tab onto the Script tab) (to add a system function to your script), or you write your own function. In the former case, once you drag the system function onto the Script tab, you then either drag a component from the Components tab onto the red placeholder fields that represent the function's parameters, or you type the input value yourself.

Using the drag and drop method is a quick way to learn the proper syntax for the various system functions.

System Functions

A system function is a function HotDocs predefines for you to enable you to perform a specific task in the HotDocs scripting language. For example, you can use the TODAY function in a script to return the current date as supplied by the system clock. For a practical application of this function, review its example script.


Operators are a special kind of system function with a streamlined syntax. While some operators (like functions) have names (for example, CONTAINS or STARTS WITH), most are represented by mathematical symbols (+, -, *, /). And instead of accepting (as input) a list of parameters, an operator accepts (as input) either one or (most commonly) two operands.

Operator syntax differs significantly from system functions too.  Functions are called like this:

FunctionName(Parameter1, Parameter2, …)

If the same function were an operator, it would look like this:

          Parameter1 FunctionName Parameter2

or more generally,

Operand1 Operator Operand2   //(for binary operators like =, !=, +, -, *, /, CONTAINS, etc.)

Operator Operand1            //(for prefix unary operators like -)

Operand1 Operator            //(for postfix unary operators like %, DAYS, MONTHS, or YEARS)

Like functions, operators always evaluate to a single value.


Here is an expression that uses the + operator to add a known value (65) to an unknown value (Birth Year):

                Birth Year + 65

The result of the above is whatever Birth Year evaluates to, plus 65 more years.

Custom Functions

A custom functions is any function you define; such a function in HotDocs is called a computation. You often use computations when writing a script, whether in another computation, or in a dialog script.

Common Reference Topics

Among others, the following reference topics relate to this conceptual area: