ASCEND Instruction
The ASCEND instruction sorts a list of answers (generated from a repeated dialog) in ascending order by a specified variable from that dialog.
The ASCEND instruction is only available when you are creating a computation but you can access the same functionality from the Field Editor when you're adding a repeated region in a template.
You can use an ASCEND instruction in a computation to provide the same functionality as the Sort answers by this variable property in the Field Editor when you select Sort ascending. To further sort the list (like using the Then sort answers by this variable property in the field editor) you can add a second ASCEND or DESCEND instruction.
You can only use an ASCEND instruction between a REPEAT instruction and an END REPEAT instruction.
Instruction name | Model | After you drag and drop the model into the script tab: |
ASCEND | ASCEND ⟦VAR⟧ | Replace ⟦VAR⟧ with the variable (from the repeated dialog) that you want HotDocs to use to sort the list of answers. |
Example
Create a text computation with the following script to insert a list of clients in alphabetical order, from A to Z. Even though it lists Client First Name first, it sorts by Client Last Name:
""
REPEAT Client Information
ASCEND Client Last Name
RESULT + Client First Name + " " + Client Last Name + "
"
END REPEAT
The first empty set of quotation marks sets the computation value to nothing. Then, the repeated dialog, Client Information, asks for each client’s first and last name. Next, the ASCEND instruction sorts the list of names by last name. Finally, the RESULT expression tells HotDocs to merge the names in the document.