Appendix B. Expression function reference
All functions, with examples evaluated against the guide's sample shipment (examples-data.json). Optional arguments are in [brackets].
In the designer, the Functions link under every expression box opens this page.
Missing values are treated gracefully: text functions treat them as empty text, and number functions ignore them.
Lists and totals
| Function |
Returns |
count(list) |
The number of items |
sum(list, ['field']) |
The total of a field over the items (or of the items themselves) |
avg(list, ['field']) |
The average (0 for an empty list) |
min(list, ['field']), max(list, ['field']) |
The smallest / largest value. Also min(a, b, c…) / max(a, b, c…) |
join(list, [separator]) |
The items joined into text, separated by , unless you give a separator |
len(x) |
The length of a text or the number of items in a list |
count(items) → 3
sum(items, 'qty') → 82
avg(items, 'qty') → 27.333333333333332
min(items, 'qty') → 10
max(items, 'qty') → 48
max(3, 7, 5) → 7
join(poNumbers, ' / ') → PO-780100 / PO-780137 / PO-780174
join(poNumbers) → PO-780100, PO-780137, PO-780174
len(poNumbers) → 3
len(orderNumber) → 9
The field argument can be a path into each item: sum(orders, 'totals.weight').
Numbers
| Function |
Returns |
round(n, [decimals]) |
Rounded to the given decimals (default 0) |
floor(n), ceil(n) |
Rounded down / up to a whole number |
abs(n) |
The value without its sign |
formatNumber(n, [decimals]) |
Text with thousands separators in the document language. Without decimals, as many as needed |
formatCurrency(n, [code]) |
Money in the document language. code is an ISO currency code (default USD) |
round(totalWeight) → 2942
round(totalWeight, 1) → 2942.5
floor(9.99) → 9
ceil(9.01) → 10
abs(-5) → 5
formatNumber(totalWeight) → 2,942.456
formatNumber(totalWeight, 2) → 2,942.46
formatCurrency(declaredValue) → $1,250.00
formatCurrency(declaredValue, 'EUR') → €1,250.00
# locale: fr-FR
formatCurrency(declaredValue, 'EUR') → 1 250,00 €
Text
| Function |
Returns |
upper(s), lower(s) |
UPPERCASE / lowercase |
trim(s) |
Without leading and trailing spaces |
concat(a, b, …) |
All arguments joined together |
substr(s, start, [length]) |
Part of the text, from position start (0 = first character) |
replace(s, find, with) |
Every occurrence of find replaced |
pad(s, length, [char]) |
Padded on the left to length with char (default space). Maximum length 10,000 |
truncate(s, length) |
Cut to length characters, ending in … when shortened |
json(x) |
The value written as JSON text (useful for QR codes) |
upper(shipTo.city) → COLUMBUS
lower('PREPAID') → prepaid
trim(' A-02-A-01 ') → A-02-A-01
concat(shipTo.city, ', ', shipTo.state) → Columbus, OH
substr(orderNumber, 3) → 104412
substr(sscc, 1, 7) → 0614141
replace(orderNumber, '-', '') → SO104412
pad(carrier.proNumber, 10, '0') → 0078121007
pad('7', 3) → " 7"
truncate(items[1].description, 15) → Power bank 20,…
json(carrier) → {"name":"Southeastern Freight Lines","scac":"SEFL","proNumber":"78121007"}
Dates
| Function |
Returns |
formatDate(d, [pattern]) |
The date as text (default pattern MM/DD/YYYY). See the token table in chapter 6 |
today() |
The current date and time (same as now) |
formatDate(orderDate) → 10/18/2026
formatDate(shipDate, 'ddd, MMM D YYYY h:mm A') → Tue, Oct 20 2026 3:45 PM
formatDate(today(), 'YYYY-MM-DD') → 2026-10-20
formatDate(now, 'YYMMDD') → 261020
Logic
| Function |
Returns |
if(condition, a, b) |
a if the condition is true, otherwise b (same as condition ? a : b) |
coalesce(a, b, …) |
The first argument that isn't missing or empty text |
if(hazmat, 'HAZMAT', 'NON-HAZMAT') → HAZMAT
if(cartons > 1, 'cartons', 'carton') → cartons
coalesce(notes, shipTo.attention, 'None') → None
coalesce(customer.code, customer.name) → NW-55021
Operators (summary)
| Kind |
Operators |
| Arithmetic |
+ - * / % (and + joins text) |
| Comparison |
== != === !== < <= > >= |
| Logic |
&& (and), || (or), ! (not), ?? (default for missing), a ? b : c |
| Grouping and literals |
( ), 'text' / "text", 123, 1.5, true, false, null, [a, b] |
Limits
To keep rendering fast and safe, an expression's text result may be at most 1,000,000 characters, pad at most 10,000, and expressions at most 10,000
characters long and nested at most 100 levels deep. A result over a limit prints empty and produces a warning.