You are here:
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 |
-
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 If you know that you don't have a number larger than 999,000, remove theCurrencyFieldString_Mline.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) - Replace CurrencyField with the name of your specific currency field.
- Copy this code into Spiff one piece at a time.
- Add other formatting such as currency symbols to the top level.
Did this article solve your issue?
Let us know so we can improve!

