HDAPIGetAnswer Method
This function gets the answer value for a variable. It can also get a single (indexed) value from a repeated answer.

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

JavaScript
function GetAnswer(vName, ndx, valType);

Parameters

vName
Type: SystemString
A variable name.
ndx
Type: SystemString
[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: SystemString
[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.

Return Value

Type: object
The requested value.
  • 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 reprsented 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.
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 retrieve an answer for one of those variables on Dialog1:
  • "0:-1:-1:-1" represents the first iteration of Dialog1, and could be used to request answers for variables at that iteration.
  • "1:-1:-1:-1" represents the second iteration of Dialog1, and could be used to request 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 requesting an answer for a variable 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