The ADD instruction enables you to add options to a Multiple Choice variable.
The ADD instruction model is only available in Component Studio when you are creating a computation.
Before you can add new options to a multiple choice variable, you first must clear the existing options using a CLEAR instruction. Once the options are empty, you can use the ADD instruction to add the new options.
You can use the ADD instruction in two ways:
When you're providing individual text string for the ADD instruction, you can use a vertical bar to separate the option text from the text you want HotDocs to use as a prompt (for example: ADD "Employed|You are currently employed" TO EmploymentStatus). In the interview the template user sees the second section ("You are currently employed") but during assembly HotDocs replaces the placeholder fields with the first section ("Employed").
Instruction name | Model | After you drag and drop the model into the script tab: |
ADD | ADD ⟦TEXT⟧ TO ⟦MULT_CHOICE_VAR⟧ | Replace ⟦TEXT⟧ with a text string you want to add to the multiple choice variable or with a text variable whose answers you want to add to the multiple choice variable as options. Replace ⟦MULT_CHOICE_VAR⟧ with the multiple choice variable whose options you want to manipulate. |
A template author is updating their template for a will. At the start of the interview, they need to ask the client their marital status, if they have any children, and if any of those children are under 18. To do this, the template author currently has one multiple choice variable that contains all the possible options (single without children, single with young children, single with adult children, married without children, etc). While this use of the multiple choice variable works, the template author has found that their template users spend too much time choosing from the long list of options.
To save time during the interview, the template author wants a multiple choice containing only the options that are relevant to the client. So, rather than using one large multiple choice variable, they create two smaller ones. The first one (MaritalStatus) asks for the client's marital status ("single" or "married"), then the second one (ChildOptions) uses that answer to show only the relevant child options (no children, young children, or adult children).
To fill the options list in the second multiple choice variable, they create a computation and type the following in the script tab:
CLEAR ChildOptions
IF MaritalStatus = "single"
ADD "single with no children|The client is single and has no children" TO ChildOptions
ADD "single with young children|The client is single and has children under the age of 18" TO ChildOptions
ADD "single with adult children|The client is single and has children who are all over the age of 18" TO ChildOptions
ELSE IF MaritalStatus = "married"
ADD "married with no children|The client is married and has no children" TO ChildOptions
ADD "married with young children|The client is married and has children under the age of 18" TO ChildOptions
ADD "married with adult children|The client is married and has children who are all over the age of 18" TO ChildOptions
END IF
The computation first uses the CLEAR instruction to remove any existing options from the ChildOptions multiple choice variable. Then the IF instruction checks if the template user selected "single" from the MaritalStatus multiple choice variable. If they did, HotDocs populates the ChildOptions multiple choice variable with the three "single" options and the three "single" prompts. If the template user didn't select "single", the ELSE IF instruction checks if they selected "married"; if they did, then HotDocs populates the ChildOptions multiple choice variable with the three "married" options and the three "married" prompts. The END IF instruction closes the list of conditional options.
After you download the example template, you can import the template to any workspace to see this example code in action.