Combine Answers From Two Lists Into One
In some templates, you may want to combine lists of repeated variables into one. For example, you may want to create a list of signers in a will. Since the signers may include both beneficiaries and fiduciaries, you want to merge both lists into one. Because some fiduciaries may also be beneficiaries, you will also want to remove any duplicate names. You can create a computation that uses the WHILE instruction to combine these lists.
This example shows how to combine a list of beneficiaries and fiduciaries into a single list of signers. The Beneficiary Information dialog is repeated in the first part of this script, and as answers are entered, their values are set to be used for Signer Name (which is the variable that will be repeated to insert all the names of the signers). Then, in the second part of the script, as the Fiduciary Information dialog is repeated, HotDocs uses the WHILE instruction to test whether the name of the fiduciary is the same as any of the beneficiary names. If it is not, it will likewise be added to the Signer Information dialog.
The final part of the script makes sure that there are not any extraneous answers in the Signer Information dialog. For example, if the user enters five fiduciary names, but then removes two of them, this part of the script also removes those extra names from the list of signers.