ANS-1254 · PRINTING, PDF & EMAIL TEMPLATES

How to Perform Arithmetic Operations on Currency Fields in NetSuite Advanced PDF?

Learn how to correctly sum currency values in NetSuite Advanced PDF templates while preserving their native currency formatting using FreeMarker.

Short answer

To perform arithmetic on currency fields in NetSuite Advanced PDF without losing formatting, use FreeMarker's ?string.currency built-in. This ensures that the sum of fields like ${record.total} and ${record.custbody_applied_amount} retains its proper currency display, preventing raw numerical output in your generated documents.

Scenario

When customizing NetSuite Advanced PDF/HTML templates, users often need to perform arithmetic operations, such as addition, on transaction body currency fields. A common challenge arises when simply adding these fields, as the resulting sum frequently loses its intended currency formatting, appearing as a plain number instead of a formatted currency value.

Solution

Consider two transaction body fields:

${record.total}
${record.custbody_applied_amount}

Simply adding these fields, as shown below, will result in the loss of currency formatting:

${record.total + record.custbody_applied_amount}

To preserve the currency formatting when performing arithmetic operations, utilize FreeMarker's ?string.currency built-in. This ensures the sum is displayed in the correct currency format:

${(record.total + record.custbody_applied_amount)?string.currency}

Expert NetSuite Support

Need help with this NetSuite issue?

Printing, PDF & Email Templates consulting and configuration support

Talk to a consultant