Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Currency Conversion


Level 1

Hi  All

I have a field on the Form where user enters currency in numbers and a dropdown where he selects the currency( options may be all foregin currency like USD, Yen, etc etc).

The problem statement is that I want to convert the currency into Dollars while storing in backend,Any idea what would be the best way to implement this.If we put a javascipt formula then the problem would be that the exchange rate keeps on changing.Another approach would be to store the exchange rate in DB or in configuration.

Kindly assist.

Thanks in advance,


Leena Jain

2 Replies


Level 10

Hi Leena Jain,

I've a couple of suggestions.  Yahoo have a webservice you can use, but you might want to check the terms and conditions.  Here is a sample calling the API.  If you can't use the Yahoo webservice then the sample should get you started calling any webservice returning a JSON result.  https://sites.google.com/site/livecycledesignercookbooks/home/YahooAPI.pdf?attredirects=0&d=1

(there are probably more currencies supported by Yahoo, I've only loaded a sample into the drop down controls)

Another option would be to load a xml file from a webserver, this sample loads the European Central Bank file they produce after each trading day.


(I don't believe there is any restrictions on accessing this file, but it only includes a subset of currencies ... still this sample would be easily modified to handle your own xml file) ... check the preOpen event.

(Both samples might give you warning messages depending on your installation configuration, but offer the "Don't ask again" option.