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

SELECTION Function

The SELECTION function gets a specific answer from a Multi Select variable or table variable, identified by the index number you specify.  

The selected answers for table and multi select variables have an index value, used to identify the order in which answers appear. The first answer a user selects has an index of 1, the next selected answer has an index of 2, and so on.

For example, suppose you have a multi select variable, BandMembers. The variable has the following options, in order: "John", "Paul", and "George". A user selects options "Paul" and "George". Using SELECTION(BandMembers, 2) in a script will return a result of "George". This is because the answer "George" is the second answer selected in the variable, so it has an index value of 2.

Function name SELECTION
Model

SELECTION([m:TABLE_VAR, MULT_SELECT_VAR], [index:NUM])

Parameters: The SELECTION function requires you to replace two parameters:

m: MULT_CHOICE_VAR
TABLE_VAR

The function retrieves options from the Table variable or Multi Select variable you specify.

NUM

Specifies the index from which to retrieve a value from the Table/Multi Select variable specified above.
Result A text value.

Example

The following example iterates through the answers selected in a Multi Select variable, using a WHILE loop, and adds them to a text variable (MemberName) in a repeating dialog. The COUNT function counts the number of selections in a Multi Select variable, giving us a limit for the WHILE loop.

SET i TO 1

WHILE i <= COUNT(BandMembers)

SET MemberName[i] TO SELECTION(BandMembers, i)

INCREMENT i

END WHILE