Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to convert the currency value "USD" to "GBP"

Rama Rao
Tera Contributor

Hello,

We have a requirement that there are two fields "Currency Dollar" and "Currency Pound". Dollar amount needs to be converted to a pound 

 

Could you please anyone help me with this?

 

Thanks in advance,

1 ACCEPTED SOLUTION

Anirudh Pathak
Mega Sage

Hi @Rama Rao ,

Here is a sample code you can try -

var conv = new sn_currency.GlideCurrencyConverter('USD', 'GBP');
conv.setAmount(100);
var convertValues = conv.convert();
gs.info('Exchanged Amount: ' + convertValues.getAmount());

 Please follow the below links, here you will find detailed explanation on how to convert currency- 

https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server/sn_currency-namespace/Gl...

 

https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server/sn_currency-namespace/Gl...

View solution in original post

7 REPLIES 7

Anirudh Pathak
Mega Sage

Hi @Rama Rao ,

Here is a sample code you can try -

var conv = new sn_currency.GlideCurrencyConverter('USD', 'GBP');
conv.setAmount(100);
var convertValues = conv.convert();
gs.info('Exchanged Amount: ' + convertValues.getAmount());

 Please follow the below links, here you will find detailed explanation on how to convert currency- 

https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server/sn_currency-namespace/Gl...

 

https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server/sn_currency-namespace/Gl...

Hello @Anirudh Pathak ,

 

Thanks for the quick response.

How it works? and from which release does this code work?

 

Hi @Rama Rao 

 

Conversion rates are stored in the fx_rate table. Each record contains the conversion rate from a given currency to the Euro. The rates are updated daily from the ECB website by a scheduled job called ECB Exchange Rate Load.

 

The code shared above will work for all release.


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hello @Sohail Khilji ,

 

I have tried and not working properly. Could you please help me and correct the code?

Note: The created new fields are type of integer