Number Format Helper
This page explains the custom number and number0 helpers from your template helper library.
Use these helpers to format numeric values with a format pattern and language setting.
number– format a number usingformatand optionalsetLangnumber0– same asnumber, but returns0when input is undefined
Function name meaning (quick reference)
number(thisNumber, format, setLang)= format a numeric valuenumber0(thisNumber, format, setLang)= format a numeric value, with0fallback for undefined inputformat= numeric format pattern stringsetLang= language code used by formatter (default:en-US)
number
Formats a number using a format pattern.
From implementation behavior:
- If
thisNumberisundefined, returns empty string - If
formatis not a string, defaults to0,0.00 - If
setLangis not provided, defaults toen-US
Expected result: 1,234,567.80
number0
Formats a number the same way as number, but when input is undefined it returns 0.
Expected result: 0 (when field is undefined)
Format examples
Use different patterns depending on display needs.
Two decimals with separators
Expected result: 9,876,543.21
Integer with separators
Expected result: 9,876,543
Fixed 3 decimals
Expected result: 52.700
Practical end-to-end example
Best Practices
- Always pass an explicit format string for consistent output.
- Keep language code explicit when templates are shared across regions.
- Use
number0when you prefer fallback0for undefined values. - Test formatting with real record data before publishing templates.
Common Use Cases
How do I format a number with thousands separators and 2 decimals?
Use the 0,0.00 format pattern:
Result: 9,876,543.21
How do I display a whole number without decimals?
Use the 0,0 format pattern:
Result: 9,876,543
How do I show a value as 0 when a field is undefined?
Use number0 instead of number:
Result: 0 (when field is missing)
How do I format numbers for different languages?
Change the language code in the third parameter:
Result:
- German: 1.234.567,89 (periods as thousands, comma as decimal)
- French: 1 234 567,89 (spaces as thousands, comma as decimal)
How do I create an invoice with consistent number formatting?
Apply the same format to all numeric fields: