Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Print Template Syntax Reference

The following is a reference to assist you when creating print templates. The syntax required for inserting field variables, formulas, conditions, and other elements are listed below. 

Field Variables

Field variables can be inserted into print templates so that the field's value is displayed in the document when the print template runs.

The general form for field variables is $FieldLabel.  For example, in the People table the variable for the Login field is $login.

You can construct chains of field variables to find values in other tables linked to the current record. These are in the form $Field1.Field2 where Field2 references a field in another table linked through Field1. Field variable chains must be constructed manually by locating the appropriate field names in each table.




$formula($login)Insert the Login value.
$formula($account_rep.backup_person)Insert the name of the Account Rep's backup person.
$formula($related123123123)Insert a related table from the current record.

View or Download Field Variables

A list of field variables for the current table can be displayed when creating or editing a print template.

Print Template Wizard

  • Click Show Field Variables to open the Formula Help wizard with a list of the Fields, Global Variables, and Functions.
  • Click Download Template to save an MS Word file which lists the field name and field label for each field in the current table.

Formulas and Conditions

Formulas and conditions are used in print templates to calculate totals, insert different fields based on the values, and insert or delete text when a condition is met. A longer list of available formulas can be found in the Formula Help window, available from the Mass Edit Wizard and other system locations.

The following formulas and examples represent the most common uses and will help you create complex print templates. 

Basic Formulas

Standard mathematical operations can be used with numeric data types such as integer, floating point, and calculated result fields.





$formula($contract_amount*$discount_percentage)Multiply the Contract Amount by the Discount Percentage
$formula($total_cost - $refund_amount)Subtract the Refund Amount from the Total Cost


Concatenate Strings

Use the following syntax to concatenate field values with other text strings. For example, inserting a field value into a sentence.



The variables may be text strings, field variables, or other formulas and variables.

Text strings must be surround in "double quotes" while variables and formulas do not.


Example formulaOutput
$formula(concat("Your account representative is ",$account_rep,"."))Your account representative is Hector Gomez.
$formula(concat($company_name," Support Contract")) Agiloft Support Contract.



Dateformat() is used to display a date/time field in a particular format, often for localization. Dateformat() takes two arguments: the desired pattern format, and the field variable. Date time patterns are indicated with a series of letters that represent elements such as month, day in month, day of week, year, hour, and minute. For a full list of possible formats see this page from Java about SimpleDateFormat().


dateformat("output pattern","$field")
Date and time patternsExample output
"MMMMM"July (name of month)
"d"10 (day of month)



The following results are expected when $contract_start_date evaluates to February 10, 2016 at 01:00:00.

10. Inserts which day of the month the contract starts.
February. Inserts the full text name of the month.
2016. Inserts the year of the contract start date.
$formula(dateformat("YYYY",NOW()))Inserts the current year when the print template runs.

Conditional Text, Paragraphs, or Clauses

A common requirement is whether to display words, multiple lines, or paragraphs of text based on the values in a record or a condition based on those values. Conditions can use a full range of logical operators such as == (equivalency), != (not equal), >, <, >=, <=.

Ternary Operator

Short conditional statements can be inserted with the ternary operator "a ? b : c". This works like an if-else statement, as follows: if the condition "a" evaluates true, then insert "b"; if "a" is false, insert "c".


$formula($condition ? "True Output" : "False output")


FormulaExplanation / Output
$formula($authorized_contract==Yes ? "'Authorized contractor' means a third party contracted to develop or assist with the development of an Authorized Application." : "")Inserts the sentence "'Authorized contractor' means a third party contracted to develop or assist with the development of an Authorized Application." if the Authorized Contract field value is Yes; otherwise, a blank space is inserted.
$formula( (isEmpty($company_id.fax)) ? "" : "Fax: " + $company_id.fax)If the company's linked Fax field is empty, insert nothing. If the Fax field is not empty, insert "Fax: 555-111-2134."

Conditional Paragraphs using $startif

Use the $startif() command in a print template if some paragraphs of text should only be included under certain conditions. For example, suppose a certain liability clause only appears in a printed contract when the contract amount is over $50,000. The conditional text comes after the $startif($condition) and is followed by $endif to close the statement.


Paragraph 1
Paragraph 2


$startif($contract_amount > 50000)

Contracts over $50,000 require an additional insurance certificate.


If the Contract Amount is over 50,000, the paragraph appears in the final document.
If the Contract Amount is less than 50,000, the paragraph is deleted.


Your extended warranty is in effect until $formula($warranty_end_date).


If the Extended Warranty field is Yes, insert the sentence listing the Warranty End Date.


The isEmpty operator checks whether a field has a value or not, and is formatted as follows:


This will return true when the $field is null or empty and false if the field has a value.

New line or insert line break

\n within a print template formula creates a new line. This can help start new paragraphs in certain cases.

Merge Documents

The $merge command can be used to merge multiple files held in a single field, or files held in multiple fields into one final document.

Using the $merge($fieldname) command within a print template will merge all attached .docx/.html files from the field in the current record into the resulting print template's .docx file. Documents held in a versioned file field will be merged in the order in which they were uploaded or appended to the field.


To merge multiple documents held in a single file field with versioning or multiple files enabled:


To merge multiple documents held in separate file fields, use the format:

$merge($field1) $merge($field2) $merge($field3) ...

This makes it possible to compile a large PDF or Word document from several attachments.

The $merge command must be placed within the body of the print template. This function will not work if the $merge function is placed within a table, the header, or footer of the template.

  • No labels