windowHDAnsSetVal Method
This function sets the answer value for a variable. It can also set a single (indexed) value in a repeated answer.

JavaScript API: Direct
Assembly: api.js Version: 1.0.0.0 (1.0.0.0)
Syntax

JavaScript
function HDAnsSetVal(vName, value, ndx, valType);

Parameters

vName
Type: string
Variable name.
value
Type: object
New value to be set.
  • Text, Number or True/False values are represented by native JavaScript strings, numbers or Boolean values, respectively.
  • Date values are represented by native JavaScript Date objects.
  • Multiple Choice values are represented by native JavaScript strings. Pipe (|) characters within the string separate the individual values of a multiple-select value (e.g., "Option A|Option C").
  • Unanswered values are representing using null.
ndx
Type: string
[optional] A string of numeric values delimited by colons (:), which represents the 0-based repeat index at each of the four possible levels of repetition. If no index is given, HotDocs assumes the variable is not repeated (equivalent to an index of "-1:-1:-1:-1").
valType
Type: string
[optional] The two-character type of variable (TX, NU, DA, TF, MC). If the answer collection contains answers of different type for the same variable name (e.g., one template has a Text variable named "Employee Name" and an inserted template has a Multiple Choice variable named "Employee Name"), specifying the type is important in order to get the expected value from the answer set. If the type is omitted, the first answer found will be returned.
Remarks

The ndx parameter is a string of numeric values delimited by colons (:), which represents the 0-based repeat index at each of the four possible levels of repetition. For example, suppose a dialog (Dialog1) containing several variables is repeated, and you're trying to set answers for a variable on that dialog:
  • "0:-1:-1:-1" represents the first iteration of Dialog1, and could be used to set answers for variables at that iteration.
  • "1:-1:-1:-1" represents the second iteration of Dialog1, and could be used to set answers for variable at that iteration.
For a more complex (nested) example, suppose Dialog1 is repeated (as above), but Dialog2 (also repeated) is a child of Dialog1. You are setting answers for variables on Dialog2:
  • "0:0:-1:-1" represents the first iteration of Dialog1's first iteration of Dialog2.
  • "2:4:-1:-1" represents the third iteration of Dialog1's fifth iteration of Dialog2.

For more information about answers and repeat indexing, see HotDocs Answers.

See Also

Reference