Formatting of Currency and Number Fields

When outputting to Word, PowerPoint, or PDF files, the merge fields with data type currency or number can be formatted.

*This function is a feature of Office File Creator Ver.2. For Ver.1, refer to Formatting of Currency and Number Fields (Ver.1).

 

Examples of Use

  • Output the number of decimal places in a currency field rounded to two places.

 

 

Default Formatting for Currency and Numeric Fields

When outputting to Word, PowerPoint, or PDF, the following formatting is applied by default to currency and number fields.

  • There is a comma delimiter, the same as the Salesforce record screen.
  • Decimal digits are output according to the field definition. If a value exceeding the number of digits in the field definition is stored in the record value, it will be rounded to the number of digits in the field definition.

 

*When outputting to Excel, record values are output as they are without formatting.

 

 

Merge Fields Settings

Set up the currency and number merge fields in the template file in the following format.

 

Merge Fields Format

{!Object API Name.Field API Name, Format;Minus Format, Rounding Mode}

*Do not enclose the format pattern in the double quotation " or single quotation ', but set it directly.

 

Format;Minus Format

Specify the three-digit separator, the number of decimal places, and the decimal rounding mode. The minus format is optional and should be specified only if it differs from the positive value format. When outputting the currency symbol, give it before or after the format.

 

  • ###0

Rounded to the nearest whole number.

  • #,##0

1000 or more, separated by 3-digit commas and rounded to the nearest whole number.

  • #,##0.0

1000 or more 3-digit comma-separated, rounded to one decimal place."0" followed by 0 for the number of digits displayed.

  • #,##0;▲#,##0

1000 or more, separated by 3-digit commas, rounded to the nearest whole number. Minus signs are indicated by ▲.

 

*EU formatting patterns are also available.

#. ##0,0 ・・・ 3-digit period separator, decimal comma

## ###,0 ・・・ 3-digit separator space, decimal point comma

 

e.g. {!Case.TestCurrency__c, $#,##0.0}

Result \1,234.5

 

Rounding Mode

Specify one of the following. Rounding mode can be omitted and if omitted, the default "HALF_UP" is applied.

e.g. {!Case.TestCurrency__c, $#,##0, DOWN}

 

Rounding Mode Description
CEILING Rounds towards positive infinity. That is, if the result is positive, this mode behaves the same as the UP rounding mode; if the result is negative, it behaves the same as the DOWN rounding mode. Note that this rounding mode never decreases the calculated value. For example:

Input number 5.5: CEILING round mode result: 6

Input number 1.1: CEILING round mode result: 2

Input number -1.1: CEILING round mode result: -1

Input number -2.7: CEILING round mode result: -2

DOWN Rounds towards zero. This rounding mode always discards any fractions (decimal points) prior to executing. Note that this rounding mode never increases the magnitude of the calculated value. For example:

Input number 5.5: DOWN round mode result: 5

Input number 1.1: DOWN round mode result: 1

Input number -1.1: DOWN round mode result: -1

Input number -2.7: DOWN round mode result: -2

FLOOR Rounds towards negative infinity. That is, if the result is positive, this mode behaves the same as theDOWN rounding mode; if negative, this mode behaves the same as the UP rounding mode. Note that this rounding mode never increases the calculated value. For example:

Input number 5.5: FLOOR round mode result: 5

Input number 1.1: FLOOR round mode result: 1

Input number -1.1: FLOOR round mode result: -2

Input number -2.7: FLOOR round mode result: -3

HALF_DOWN Rounds towards the “nearest neighbor” unless both neighbors are equidistant, in which case this mode rounds down. This rounding mode behaves the same as the UP rounding mode if the discarded fraction (decimal point) is > 0.5; otherwise, it behaves the same as DOWN rounding mode. For example:

Input number 5.5: HALF_DOWN round mode result: 5

Input number 1.1: HALF_DOWN round mode result: 1

Input number -1.1: HALF_DOWN round mode result: -1

Input number -2.7: HALF_DOWN round mode result: -3

HALF_EVEN Rounds towards the “nearest neighbor” unless both neighbors are equidistant, in which case, this mode rounds towards the even neighbor. This rounding mode behaves the same as the HALF_UP rounding mode if the digit to the left of the discarded fraction (decimal point) is odd. It behaves the same as the HALF_DOWN rounding method if it is even. For example:

Input number 5.5: HALF_EVEN round mode result: 6

Input number 1.1: HALF_EVEN round mode result: 1

Input number -1.1: HALF_EVEN round mode result: -1

Input number -2.7: HALF_EVEN round mode result: -3

HALF_UP Rounds towards the “nearest neighbor” unless both neighbors are equidistant, in which case, this mode rounds up. This rounding method behaves the same as the UP rounding method if the discarded fraction (decimal point) is >= 0.5; otherwise, this rounding method behaves the same as the DOWN rounding method. For example:

Input number 5.5: HALF_UP round mode result: 6

Input number 1.1: HALF_UP round mode result: 1

Input number -1.1: HALF_UP round mode result: -1

Input number -2.7: HALF_UP round mode result: -3

UP Rounds away from zero. This rounding mode always truncates any fractions (decimal points) prior to executing. Note that this rounding mode never decreases the magnitude of the calculated value. For example:

Input number 5.5: UP round mode result: 6

Input number 1.1: UP round mode result: 2

Input number -1.1: UP round mode result: -2

Input number -2.7: UP round mode result: -3

Rounding mode follows Salesforce specifications.

https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_decimal.htm%23apex_System_Decimal_format

 

 

Example of Merge Fields

e.g. The object is Case, the field is TestCurrency c (Currency), and the field value is 1234567.89.

*If rounding mode is omitted, the default "HALF_UP" rounding is applied.

Format Pattern Result Example of Merge Field
$###0 $1234568 {!Case.TestCurrency__c, $###0}
$#,##0 $1,234,568 {!Case.TestCurrency__c, $#,##0}
$#,##0.0 $1,234,567.9 {!Case.TestCurrency__c, $#,##0.0}
$#,##0.00 $1,234,567.89 {!Case.TestCurrency__c, $#,##0.00}
$#,##0.000 $1,234,567.890 {!Case.TestCurrency__c, $#,##0.000}
$#,##0.0000 $1,234,567.8900 {!Case.TestCurrency__c, $#,##0.0000}
$#,##0, DOWN $1,234,567 {!Case.TestCurrency__c, $#,##0, DOWN}
$#,##0;$▲#,##0, DOWN $1,234,567

minus value: $▲1,234,567

{!Case.TestCurrency__c, $#,##0;$▲#,##0, DOWN}

 

 

Note

When outputting to Excel, it cannot be formatted the merge field. Format the cells in the template file.