The FORMAT function evaluates an expression and then converts its resulting date, number or true/false value into a text value.
Because the FORMAT function can return other types of variables as text, it is useful for concatenating and building longer strings of text.
The function formats the expression according to the format example you provide.
Function Attributes | Details |
Name | FORMAT |
Interface Location | Component Studio > Computation Editor or Dialog Editor > Models tab > Text Functions and Operators |
Model | FORMAT ( v:EXPRESSION, example:TEXT ) |
Parameters | This function requires you to provide two parameters |
v: EXPRESSION |
The v parameter (v stands for value - i.e., the value HotDocs returns after evaluating the expression) tells the HotDocs what to format as a text value. Replace v:EXPRESSION with the expression you want HotDocs to evaluate and format as a text value. |
example:TEXT |
The example parameter tells the function how you want your text to look. Replace example:TEXT with an example of the text format that you want. The format must be recognizable by HotDocs, for example: "LIKE THIS". |
Result | A text value, formatted in accordance with the example you provide. |
Assume you want to create a list of items (e.g., ItemName, a Text variable) with their associated monetary values (e.g., ItemAmount a Number variable). Since these variables are different types, you cannot concatenate them without first formatting the number value as a text value:
"" REPEAT Purchase Information RESULT + Item Name + ", " + FORMAT( Item Amount, "$9,999.00" ) + " " END REPEAT
In this script, you would first set the Computation Result Type property to Text. The script repeats PurchaseInformation and then places the answers for both ItemName and ItemAmount (formatted to appear as a text value) in the same text string, separated by a comma. If PurchaseInformation is answered more than once, HotDocs manually inserts a hard return (as shown before the END REPEAT) to create a column of amounts.
After you download the example template, you can import the template to any workspace to see this example code in action: