Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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. 

Table of Contents
maxLevel2

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.

...

Code Block
$formula($field) 
$formula($field1.field2)

Examples

$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.

Note that if you are putting dollar signs ($) into a print template to format values in a number field, you can enter a backslash (\) to ensure that the dollar sign does not get eliminated by the system while it is processing the variables and formulas in the print template. For example, \$25,000 will appear as $25,000. You can configure the system so that it does not eliminate the backslash by changing the value of the Keep slash prior escaped dollar sign global variable to Yes. 

View or Download Field Variables

...

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.

...

Code Block
$formula($equation)

 

Examples

$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

 

Anchor
concatenate-strings
concatenate-strings
Concatenate Strings

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

Syntax

Code Block
$formula(concat("x",$field,"z",...))

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.

Examples

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

 

Dateformat

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().

Syntax

Code Block
dateformat("output pattern","$field")
Date and time patternsExample output
"MM/dd/yy"05/31/16
"yyyy/dd/MM"2016/22/09
"MMMMM"July (name of month)
"d"10 (day of month)

 

Examples

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

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

concatenatestringsexcerpt

Excerpt Include
_concatenateStrings
_concatenateStrings
nopaneltrue

Dateformat

Hide If
displaydefault

dateformatexcerpt

Excerpt Include
_Dateformat
_Dateformat
nopaneltrue

Format Formula Outputs

Hide If
displaydefault

formatexcerpt

Excerpt Include
_format
_format
nopaneltrue

Conditional Text, Paragraphs, or Clauses

A common requirement is whether to display show 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".

Syntax

Code Block
$formula($condition ? "True Output" : "False output")
Hide If
displaydefault

ternaryoperatorsexcerpt

Excerpt Include
_ternaryOperators
_ternaryOperators
nopaneltrue

Additional Examples

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."
$formula($country=="USA"&&$city=="Redwood" ? "The company is located in Redwood, USA" : "")

Inserts the sentence "The company is located in Redwood, USA" if the Country is USA and the City is Redwood; otherwise, a blank space is inserted.

If-Then-Else Conditions to Display Field Variables

The $if statement evaluates a condition to decide which field variable to display. It is similar to the ternary operator, but the true and false outputs may only be field variables or the $merge command with an attached file field.

Syntax

Code Block
$if(condition) ? $fieldTrue : $fieldFalse

The second (else) field variable may be left out to display blank if the condition is not met.

Code Block
$if(condition) ? $fieldTrue

Or, the $merge($filefield) command may be used as an output:

Code Block
$if(condition) ? $merge($filefield) : $fieldFalse


Examples

$if ($discount_applied == "Yes") ? $percentage_discountIf a discount is applied, show the Percentage Discount field.
$if ($contract_amount > 100000) ? $related123456 : $customer.related345678If the contract amount is greater than $100,000, show the field $related123456; else, show the field $related45678 in the linked customer record.
$if ($include_appendix == "Yes") : $merge($attached_file)If an appendix should be included, merge the file held in the Attached File field.

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.

Syntax

Code Block
languagexml
$startif($condition)
Paragraph 1
Paragraph 2
$endif

Examples

$startif($contract_amount > 50000)

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

$endif

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.

$startif($extended_warranty=="Yes")

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

$endif

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

isEmpty

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

Code Block
isEmpty($field)

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.

$startif(($service_name ~= "Installation")&&($flag = "Yes"))

Lorem ipsum dolor sit amet.

$endif

If the Service Name field contains "Installation" and the Flag field is set to Yes, then show the paragraph.

This example combines conditions using && and extra parentheses surrounding the conditions.

$startif(find("Amended", concat("", $contract_updates))

Lorem ipsum dolor sit amet.

$endif


Checks if the value "Amended" is found in a multi-value choice field "Contract Updates". The concat function gets a string representation of the values in the multi-value field, and if it contains the value "Amended", returns the text below.

To handle cases where none of the values are selected, you can add the following after the startif:

|| isEmpty($contract_updates))

isEmpty returns "true" and outputs the text if none of the values are selected.

isEmpty

Hide If
displaydefault

isemptyexcerpt

Excerpt Include
_isEmpty
_isEmpty
nopaneltrue

New line or insert line break

Hide If
displaydefault

linebreakexcerpt

Excerpt Include
_lineBreak
_lineBreak
nopaneltrue

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.

Syntax

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

...

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

...

the header

...

or footer of the template, or within a table.

Hide If
displayprintable

Content by Label
showLabelsfalse
max5
spacesPROD
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ("print","template","print-template") and type = "page" and space = currentSpace()
labelsinterface navigating