Question
ASB
NZ
Last activity: 17 Sep 2024 23:11 EDT
How to format number into a currency with functions or activity?
We have a use case where we send data to the Adobe API for document generation. This data includes numbers that need to be formatted as currency (e.g., $ xxx,xxx.xx) in the generated document. Are there any out-of-the-box methods or functions available that can be used in an activity to format a decimal value into a currency? Thank you in advance.
-
Reply
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
ASB
NZ
@kasis following code snippet worked in the function
java.text.DecimalFormat df = new java.text.DecimalFormat("#,###.##");
return df.format(InputNumber);
Updated: 27 May 2024 1:03 EDT
Eclatprime Digital Private Limited
IN
Hi , @kasis For your use case if you create the Currency type property using PxCurrency control in this case and use it in your section then the value 1000 is converted to $1,000.00. In the Format sidebar, click the Cell tab, then click the Data Format pop-up menu and choose Currency. or please check if there is any NumberFormat() function available in pega as like javascript.
ASB
NZ
@Somil ShuklaIn the UI, the currency is formatted as $1,000.00, but when copied to the clipboard, it appears as 1000. We need to send the clipboard data as JSON to the Adobe API for document generation. Is there a function available that can be used in an activity to format the currency?
Maantic Inc
IN
What is the property type you're using?
ASB
NZ
@Somil Shukla It's a property of type decimal. Do you have any engine API that I can consume in the function to format a decimal value into currency?
ASB
NZ
@Bala Veera How can we define the properties of a currency? Any suggestions?
Accepted Solution
ASB
NZ
@kasis following code snippet worked in the function
java.text.DecimalFormat df = new java.text.DecimalFormat("#,###.##");
return df.format(InputNumber);