Formatting variable data

The way variable data are displayed in a template depends on two things. Firstly, the locale influences the way dates, times, numbers and currencies are formatted; see Locale. Secondly, there are functions to display a text in uppercase, apply thousands separators to numbers, etc.

The Text Helper Wizard (see Using the Helper Wizard) and the Text Script Wizard (see Using the Text Script Wizard) let you select a format or enter a format mask for each field that the script adds to the template. This topic describes the options that the wizards offer, depending on the type of field.
Reopen the Helper or script by double-clicking it in the Scripts pane.

In an expression, e.g. {{LastName}} (see Variable data in text: expressions), you can type the desired format function before the field name, e.g. {{uppperCase LastName}}. Functions in an expression are called "Helpers". For an overview of the available Format Helpers see Format Helpers.

The available formatting functions depend on the data type of the corresponding field in the Data Model. To change the type of a data field, right-click it in the Data Model and select Set Type.

You could also format data in a script using the formatter; see Standard Script API.

Date

Dates can only be formatted via a script. All data in the Data Model are initially strings (except when loaded from a CSV or Microsoft Excel file). They have to be converted to Date objects before applying a particular date format. See also: Creating a Date object from a string.

Font style

Text originating from variable data can be displayed in uppercase, lowercase or proper case.

  • Uppercase transforms all characters to uppercase.

  • Lowercase displays transforms all characters to lowercase.

  • Propercase transforms the first character of each word to uppercase and all other characters to lowercase.

Numbers and currencies

Numbers, and strings existing of digits, can be displayed as a number with a certain formatting or as an amount of money.

Spaces in a number or amount of money are transformed into non-breaking spaces to ensure that it is not split onto different lines.

  • Custom Pattern: allows you to enter a custom format mask. For example, the pattern 000000 means that the number should count six digits; leading zeros are added to numbers shorter than six digits. For an overview of pattern symbols see Number patterns and http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html. The custom pattern will only work if the actual value of the field can be converted from a text to a number.

  • Grouped displays a number with three decimal places and sets the thousands separator for the value based on the current locale; see Locale.

  • Currency displays a number as an amount of money, with a thousands separator and rounded to two decimal places, based on the current locale; see Locale.

  • Currency no symbol does the same as Currency, but omits the currency symbol.

  • ∑ (Sum) and ∑↑ (Sum Up) are used in the Professional and Enterprise editions of OL Connect.