SELECTION Function

The SELECTION function changes the number value of a Multiple Choice option you specify to a text value.

 

Function name SELECTION
Model SELECTION ( m:MULT_CHOICE_VAR, index:NUM )
Parameters: The SELECTION function requires you to replace two parameters:

m: MULT_CHOICE_VAR

The function retrieves options from the Multiple Choice variable you select.

NUM

The function indexes the Multiple Choice variable's options based on the number variable you use to replace NUM.
Result A text value.

Example

In the following example, you want to generate a list of employees that have various different work projects they need to complete. Multiple employees may work on one individual project. Once you have this list, you want to generate a work list report for each employee on the list.

To accomplish this, you first repeat a dialog (Employee List) that asks which employees are supposed to work on a given assignment (using the Multiple Choice variable, Employee Names). As HotDocs repeats this list, the UNION expression adds each selected, original name from each repetition to a new Multiple Choice variable, Unique List.

Once all of the unique answers have been added to Unique List, HotDocs then uses the SELECTION expression to retrieve each individual answer from Unique List. The result of the script merges these names in a report.

ERASE Unique List

REPEAT Employee List

SET Unique List TO UNION(Unique List, Employee Names )

END REPEAT

ERASE Project Participant

SET Index TO 1

WHILE SELECTION(Unique List, Index ) != ""

SET Project Participant[Index] TO SELECTION(Unique List, Index )

INCREMENT Index

END WHILE

Download

After you download the example template, you can import the template to any workspace to see this example code in action.