FreeMarker Formatting Method

NetSuite formatting is lost when you customize NetSuite standard fields. If you print hard-coded values which came from a custom data source or were calculated from standard fields, the format will not be consistent with the format of standard record fields. When editing the template source code, the nsformat_() formatting method makes it possible to format FreeMarker custom variables in the same way NetSuite formats standard fields. It also decreases the need for hardcoding. The nsformat_() method formats the specific string, number, date, or amount results in the same format used on a standard NetSuite field. With this formatting method, it is possible to apply localization to custom variables, ensuring consistent output.

Method

1.${nsformat_date(date|string)}

Example: ${nsformat_date(“2018-12-04T10:40:00.000”)}

Output: 4/12/2018

2. ${nsformat_datetime(date|string)}

Example: ${nsformat_datetime(“2018-12-04T10:40:00.000”)}

Output: Dec 4, 2018 10:40:00 AM

3. ${nsformat_time(date|string)}

Example: ${nsformat_time(“2018-12-04T10:40:00.000”)}

Output: 10:40:00 AM

4. ${nsformat_currency(number|string)} or with optional
second string ${nsformat_currency(number|string,
string)}

Example: ${nsformat_currency(10.20, “EUR”)}

Output: €10,20

5. ${nsformat_rate(boolean|string|number)} or with
optional second string ${nsformat_rate(number|string,
string)}

Example: ${nsformat_rate(32, “USD”)}

Output: $32.00

6. ${nsformat_number(number|string)}

Example: ${nsformat_number(“999999999”)}

Output: 999,999,999

7. ${nsformat_boolean(boolean|string|number)}

Example: ${nsformat_boolean(“true”)}

Output: Yes

8. ${nsformat_password(string)}

Example: ${nsformat_password(“p4sw0rd”)}

Output: *****

9. ${nsformat_percent(number|string)}

Example: ${nsformat_percent(“100”)}

Output: 100%

10. ${nsformat_email(string)}

Example: ${nsformat_email(“email@example.com”)}

Output: email@example.com (clickable email address)

11. ${nsformat_url(string)}

Example: ${nsformat_url(“https://www.netsuite.com”)}

Output: https://www.netsuite.com (clickable link)

Leave a comment

Your email address will not be published. Required fields are marked *