42. Use Merge Text with a Multiple Choice's "Other" Option
Description
A work-around that mimics merge text for a multiple choice variable's "Other" option.
Code
Explanation
HotDocs does not permit merge text with the "Other" option in multiple choice variables. There are, however, some adequate work-arounds. Each is explained below. The model template demonstrates Option A.
See Also, Computation 54, Referencing Multiple Choice Merge Text.
Explanation
Option A - Use a variable for the merge text. This is the simplest option since it doesn't require a computation. Instead of using HotDocs' "Other" option create your own "Other" as the last option in the list. Next create a text variable for the "Other" option and use it as the Merge Text for that option.
To do this: First insert the text variable into the document - select it - cut it - and paste it into the merge text. If you have a problem with that working you can type the Text Variable into the merge text using ALT+174 for the Left Chevron and ALT + 175 for the Right Chevron. Be sure to get the name of the text variable exactly right.
You'll then need to make sure that HotDocs asks these text variables if the user selects the "Other" option, especially if you are using HotDocs 6. This is most easily done in the same dialog where you ask the multiple choice variable via a dialog script which SHOWs or HIDEs the text variables as needed. Here is one example:
Code
Dialog Script:
HIDE AttorneyOtherName-t
HIDE AttorneyOtherInitials-t
HIDE AttorneyOtherPhone-t
IF Attorney-m = "Other"
SHOW AttorneyOtherName-t
SHOW AttorneyOtherInitials-t
SHOW AttorneyOtherPhone-t
END IF
-SEP-
CODE:
Example B - Text Variable in Computation:
IF Attorney-m = OTHER( Attorney-m )
"«Initials-t:LIKE THIS»"
ELSE
"«Attorney-m:MTC/AL»"
END IF
Example C - Compute a Value:
""
// Custom percentage
IF Percent-m = OTHER( Percent-m )
// If they included %, trim it off
IF LAST( Percent-m, 1 ) = "%"
FIRST( Percent-m, LENGTH( Percent-m ) - 1 )
END IF
// Convert it to an integer
SET Temp-n TO INTEGER( Percent-m )
// Format the merge text
"«Temp-n:nine» percent («Temp-n»%)"
// List item
ELSE
"«Percent-m:all (100%)/half (50%)/one-fourth (25%)»"
END IF
Explanation
Option B demonstrates another common approach. The premise is to first check whether the user chose from the list or used the "Other" option. To make this test, we simply check to see if MultChoice = OTHER( MultChoice ), or, in other words, whether the answer to MultChoice is the same as the value provided in MultChoice's "Other" option. If so, the user has entered "Other" text and we will need to prompt them for the merge text value. We do this by using a separate text variable to hold this value.
The example illustrates this clearly. The example uses the multiple choice variable Attorney-m to allow the user to select the name of an attorney from a list. What is needed immediately are the attorney's initials. These are provided with merge text for attorneys in the list ("MTC" for Marcus T. Cicero, "AL" for Abraham Lincoln, etc.).
The computation looks whether the chosen attorney is on the list. If it is not (an attorney name was entered in the "Other" field), we must prompt them for the initials with the Initials-t variable, then the computation returns this value. If the attorney is on the list, we simply use the merge text provided in the multiple choice variable. Notice that the merge text is indicated after a colon ":".
Option C takes a different approach. It computes a merge text value based on the text entered for "Other". The example assumes a multiple choice variable Percent-m with three options: 100%, 50%, and 25%. The template designer has provided special merge text for these values: "all (100%)", "half (50%)", and "one-fourth (25%)." The user can also enter their own custom percentage. If a custom percentage is entered, "X percent (X%)" is to be inserted.
Like the first example, this computation first checks whether a custom percentage was entered. If so, a computation is provided to format that value properly and the formatted value is returned. But if a list item was chosen, the merge text for that item is returned.
Note that Temp-n is a temporary number variable used to store the custom percent when it has been converted into an integer (be sure to set its Advanced options to "Don't warn if unanswered", "Ask only in dialog" and "Don't save in answer file").
Explanation