Convert Currency to a String in Salesforce Spiff

To show currency values with formatting such as symbols and commas in Salesforce Spiff documents or statement cards, convert the currency field to a string data type.

Required Editions

Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience
Available in: Enterprise, Unlimited, and Developer Editions
Available for an additional cost in: Professional Edition with Web Services API Enabled
User Permissions Needed
To modify currency in Spiff documents or statements:

A Spiff user role with this permission turned on.

Documents: Edit OR Statements: Edit

  1. Copy this code to a text editor.
    CurrencyFieldStringWithCommas
    concat(["$",CurrencyFieldString_M, CurrencyFieldString_K, CurrencyFieldString_H, CurrencyFieldString_Decimal])
    CurrencyFieldString_M
    if(CurrencyFieldStringIntLength<7,"",
    if(CurrencyFieldStringIntLength<10,concat([left(CurrencyFieldString,CurrencyFieldStringIntLength-6),","]),
    if(CurrencyFieldStringIntLength>=10,concat([left(CurrencyFieldString,CurrencyFieldStringIntLength-9),",",mid(CurrencyFieldString,CurrencyFieldStringIntLength-8,3),","]),
    "")))
    CurrencyFieldString_K
    if(CurrencyFieldStringIntLength<4,"",
    if(CurrencyFieldStringIntLength<7,concat([left(CurrencyFieldString,CurrencyFieldStringIntLength-3),","]),
    if(CurrencyFieldStringIntLength>=7,concat([mid(CurrencyFieldString,CurrencyFieldStringIntLength-5,3),","]),
    "")))
    CurrencyFieldString_H
    if(CurrencyFieldStringIntLength<4,left(CurrencyFieldString,3- (3-CurrencyFieldStringIntLength)),
    if(CurrencyFieldStringIntLength>=4,mid(CurrencyFieldString,CurrencyFieldStringIntLength-2,3),
    "0"))
    CurrencyFieldString_Decimal
    mid(concat([CurrencyFieldString,"0000"]),CurrencyFieldStringIntLength + 1, 3)
    CurrencyFieldStringIntLength
    search(".", CurrencyFieldString) -1
    CurrencyFieldString
    right(concat([CurrencyField]), len(concat([CurrencyField]))-4)
    Tip
    Tip If you know that you don't have a number larger than 999,000, remove the CurrencyFieldString_M line.

    If you want to apply the same logic to multiple fields and don't want to create seven fields per display field, use this code instead.

    CurrencyFieldStringWithCommas 
    concat(["$", 
    if(CurrencyFieldStringIntLength<4,
    left(CurrencyFieldString,3- (3-CurrencyFieldStringIntLength)),
    if(CurrencyFieldStringIntLength<7,
    concat([left(CurrencyFieldString,CurrencyFieldStringIntLength-3),",",
    mid(CurrencyFieldString,4+ (CurrencyFieldStringIntLength-6) ,3)]),
    concat([left(CurrencyFieldString,CurrencyFieldStringIntLength-6),",",
    mid(CurrencyFieldString,4+ (CurrencyFieldStringIntLength-9),3),",",
    mid(CurrencyFieldString,4+ (CurrencyFieldStringIntLength-6) ,3)]))),
    mid(concat([CurrencyFieldString,"0000"]),CurrencyFieldStringIntLength+1,3)])
    CurrencyFieldStringIntLength
    search(".", CurrencyFieldString) -1
    CurrencyFieldString
    right(concat([CurrencyField]), len(concat([CurrencyField]))-4)
  2. Replace CurrencyField with the name of your specific currency field.
  3. Copy this code into Spiff one piece at a time.
  4. Add other formatting such as currency symbols to the top level.