HotDocs Author WorkflowCreate a template Add placeholders Group variables in dialogs Upload a template Create a script

DESCEND Instruction

The DESCEND instruction sorts a list of answers (generated from a repeated dialog) in descending order by a specified variable from that dialog.

The DESCEND 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 DESCEND 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 descending. To further sort the list (like using the Then sort answers by this variable property in the field editor) you can add a second DESCEND or ASCEND instruction.

You can only use an DESCEND instruction between a REPEAT instruction and an END REPEAT instruction.

Instruction name Model After you drag and drop the model into the script tab:
DESCEND DESCEND  ⟦VAR⟧ Replace ⟦VAR⟧ with the variable (from the repeated dialog) that you want HotDocs to use to sort the list of answers.


For the following script, the template author creates two variables and repeated dialog:

  • Client First Name (a Text variable)
  • Client Last Name (a Text variable)
  • Client Information (a repeated dialog containing Client First Name and Client Last Name)

Create a text computation with the following script to merge a list of clients in alphabetical order, from Z to A. Even though it lists Client First Name first, it sorts by Client Last Name:


REPEAT Client Information

DESCEND Client Last Name

RESULT + Client First Name + " " + Client Last Name + "



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 DESCEND instruction sorts the list of names by last name. Finally, the RESULT expression tells HotDocs to merge the names in the document.