Template-only functions

Some built-in functions prepare values for human readers. They format numbers (format-number), format dates and times (format-short, format-medium, format-long), and select the language version of a multilingual text (preferred-language, preferred-language-text). Their result depends on the visualisation of the notice: its language, its number format and its order of preferred languages. So you can use them only in template files, which display a notice. To select the language, they use functions that the visualisation provides when it displays the notice.

In a single expression or in a rules file, these functions are errors, which the translator reports when it translates the expression or the rules file. In a template file, you can use them in any expression: in expression blocks, in the conditions and variables of template lines, in global variables and in user-defined functions.

The examples on this page are complete template lines.

format-number

Formats a number as text, following a picture that describes the digits and separators to show.

Syntax
format-number(<number>, <picture>) → text
<number>

number. The number to format.

<picture>

text. The picture: a pattern of digits and separators, described below.

The picture is made of the following characters:

  • 0 stands for a digit that is always shown, with a zero if needed. 000 shows the number 5 as 005.

  • # stands for a digit that is shown only when it changes the value of the number. In the whole-number part, the # signs come before the 0 signs. In the decimal part, they come after them.

  • . marks the place of the decimal separator. The digits after it set the number of decimal places: 0.00 shows exactly two, and 0.## at most two.

  • , marks the place of a grouping separator, for example between thousands: #,##0.

  • % multiplies the number by 100 and shows a percent sign. ‰ multiplies it by 1000 and shows a per-mille sign.

  • ; separates the picture for positive numbers from an optional picture for negative numbers: 0.00;(0.00) shows negative numbers in brackets. Without it, negative numbers have a minus sign.

  • Any other character appears as it is, before or after the digits.

format-number rounds the number to the number of decimal places that the picture allows. When a value is exactly halfway between two possible results, it takes the one whose last digit is even: 0.125 with the picture 0.00 gives 0.12, and 0.135 gives 0.14. A number that is NaN, or that has no value, gives the text NaN.

You always write the picture with the full stop as decimal separator and the comma as grouping separator. The reader sees the separators of the visualisation. For example, with the settings of the Publications Office, #,##0.00 shows 1234.5 as 1 234,50. This applies when the picture is a text literal. When you give the picture in another way, for example in a variable, format-number uses it as it is. You must then write it with the separators of the visualisation.

An invalid picture causes an error when the template is used.

In an expression block, you can also format a number with a format option, which gives the number of decimal places, as in ${BT-00-Number|2} (see Expression block).

Restrictions

  • Templates only.

  • You must give both arguments.

Examples

WITH BT-00-Number DISPLAY ${format-number(BT-00-Number, '#,##0.00')};

Shows the number with two decimal places and grouped thousands.

WITH ND-Root DISPLAY ${format-number(count(BT-13-Text), '000')};

Shows a number with at least three digits, such as 007.

WITH ND-Root DISPLAY ${format-number(BT-00-Number, '0.00;(0.00)')};

Shows negative numbers in brackets.

From the SDK (view-templates/18.efx, without its indentation)
WITH BT-27-Lot DISPLAY #{name}: ${format-number(BT-27-Lot, '###,##0.##')} #{code|name|${concat('currency.', BT-27-Lot/@currencyID)}} ; // Estimated value

An estimated value followed by the name of its currency.

In EFX-1, the picture was optional, and you could use the function in any expression. In EFX-2, the picture is required, and you can use the function only in templates.

format-short

Formats a date, a time, or a date and a time, in a short form made of numbers.

Syntax
format-short(<date>) → text
format-short(<time>) → text
format-short(<date>, <time>) → text
<date>

date. The date to format.

<time>

time. The time to format.

The forms are:

  • a date: DD/MM/YYYY, for example 05/02/2026. The time zone of the date is not shown.

  • a time: hh:mm on a 24-hour clock, followed by a space and the time zone as +hh:mm or -hh:mm, for example 14:30 +01:00. The time zone Z is shown as +00:00. A time without time zone is followed by a space only.

  • a date and a time: the date and the time as above, separated by a space.

If the date or the time has no value, nothing is shown for it.

A template also uses this form for a date or a time that you do not format yourself. In an expression block, EFX formats a date or a time with format-short, unless a format option of the block, such as ${BT-00-StartDate|long}, chooses another form.

Restrictions

  • Templates only.

Examples

WITH ND-Root DISPLAY ${format-short(BT-00-StartDate)};
WITH ND-Root DISPLAY ${format-short(BT-00-StartDate, BT-00-StartTime)};

Shows a date and a time such as 05/02/2026 14:30 +01:00.

New in EFX-2.

format-medium

Formats a date, a time, or a date and a time, in a medium form, with a short month name.

Syntax
format-medium(<date>) → text
format-medium(<time>) → text
format-medium(<date>, <time>) → text
<date>

date. The date to format.

<time>

time. The time to format.

The forms are:

  • a date: the day as two digits, the first three letters of the name of the month, and the year, for example 05 Feb 2026. The name of the month is in the language of the visualisation. The time zone of the date is not shown.

  • a time: hh:mm:ss on a 24-hour clock, for example 14:30:00. Decimal seconds and the time zone are not shown.

  • a date and a time: the date and the time as above, separated by a space.

If the date or the time has no value, nothing is shown for it.

Restrictions

  • Templates only.

Examples

WITH ND-Root DISPLAY ${format-medium(BT-00-StartDate)};
WITH ND-Root DISPLAY ${format-medium(BT-00-StartDate, BT-00-StartTime)};

Shows a date and a time such as 05 Feb 2026 14:30:00.

New in EFX-2.

format-long

Formats a date, a time, or a date and a time, in a long form, with the full name of the month and the time zone.

Syntax
format-long(<date>) → text
format-long(<time>) → text
format-long(<date>, <time>) → text
<date>

date. The date to format.

<time>

time. The time to format.

The forms are:

  • a date: the day as two digits, the full name of the month, and the year, for example 05 February 2026. The name of the month is in the language of the visualisation. The time zone of the date is not shown.

  • a time: hh:mm:ss on a 24-hour clock, followed by a space and the time zone as +hh:mm or -hh:mm, for example 14:30:00 +01:00. The time zone Z is shown as +00:00.

  • a date and a time: the date and the time as above, separated by a space.

If the date or the time has no value, nothing is shown for it.

Restrictions

  • Templates only.

Examples

WITH ND-Root DISPLAY ${format-long(BT-00-StartDate)};

Shows a date such as 05 February 2026.

LET text:$today = format-long(current-date());
WITH ND-Root DISPLAY Printed on ${$today};

Uses the function in a global variable.

New in EFX-2.

preferred-language

Returns the language of the value of a multilingual text field that best suits the reader.

Syntax
preferred-language(<field>) → text
<field>

a reference to a multilingual text field, optionally with a predicate.

A multilingual text field has one value for each language in which the text is given. The function looks for a value in each of the following languages, in this order, and stops at the first language that it finds:

  1. the language of the visualisation;

  2. the language of the notice;

  3. the additional languages of the notice, in the order in which the notice lists them.

The result is the language identifier of that value, as written in the notice: a three-letter code such as ENG or FRA. When the field has no value in any of these languages, the result is the language of its first value. When the field has no value at all, the result has no value.

The function looks at all the values of the field from the current context together.

Restrictions

  • Templates only.

  • The argument must be a reference to a multilingual text field. Another field, or any other expression, is an error.

Examples

WITH ND-Root DISPLAY ${preferred-language(BT-00-Text-Multilingual)};
New in EFX-2.

preferred-language-text

Returns the value of a multilingual text field in the language that best suits the reader.

Syntax
preferred-language-text(<field>) → text
<field>

a reference to a multilingual text field, optionally with a predicate.

The function selects a value as described for preferred-language, and returns its text, without white space at its start and end, and with each run of white space inside it reduced to one space. When the field has no value at all, the result has no value.

The property :preferredLanguageText of a field gives the same result (see Field property).

Declare the context of the template line on the node that contains the field, not on the multilingual field itself. A template line whose context is the multilingual field repeats for each of its language versions.

Restrictions

  • Templates only.

  • The argument must be a reference to a multilingual text field. Another field, or any other expression, is an error.

Examples

WITH ND-Root DISPLAY ${preferred-language-text(BT-00-Text-Multilingual)};
WITH ND-Root DISPLAY ${upper-case(preferred-language-text(BT-00-Text-Multilingual))};

You can use the result as any other text.

New in EFX-2. EFX-1 had no such function: a template that displayed a multilingual field showed the value in the preferred language automatically. In EFX-2, you make the selection yourself.