Question on currency conversion

priya149
Mega Contributor

I am getting what i wanted to achieve but wants to clear my  concept how its working.

I wanted to convert amount of any currency into euro and created variables and mapped to INC currency field type as shown below.

BR written-

current.u_amount_in_integer = current.u_amount;
gs.log("Test123 " + current.u_amount);

Log- Test123 81647 (euro)

I am getting OOB value in euro only for USD , INR all currency, How its coming can someone explain me.

Is it coming from  fx_rate table automatically?

Is this enough to achieve my requirement or do i need to do more coding/query on fx_rate table?

 

find_real_file.png

 

4 REPLIES 4

shohebshaikh
Giga Expert

Hi,

Currency values can be converted to other currencies when stored and accessed.

Conversions can happen in these situations.
  • The currency value is converted to reference currency when stored, whether on insert or update. This means that the reference currency value is saved as well as the currency value.
  • The currency value is converted to the user’s session currency for display.
  • The value entered for a filter from currency specified in the filter is converted to the reference currency.

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.

A currency conversion from one currency to another involves two rates
  • Rate to convert from the first currency to Euro
  • Rate to convert from Euro to the second currency
Whenever a conversion is performed, the platform uses the latest conversion rates. Therefore, calculations can potentially yield unexpected results. For example:
  • Different currency values can have different rates applied to them while storing the reference currency value. Aggregation therefore can combine values at different rates and convert back at another rate.
  • A filter value is converted at current rates while the values it filters in the database can be converted at different rates. A filter for $100 at today's rate can match a value of $99 obtained at yesterday’s rates.
Note: For display purposes, the currency value used is what the user entered converted to session currency. However, for aggregation and filtering, the reference currency value is used. Using the reference currency enables currency values converted at different rates to be compared together.
 
Regards,
Shoheb

Onkar Pandav
Tera Guru

Hi,

Please check the attachment. That might help you.

Thanks.

Hi,

I have already checked those all docs available.

I know Conversion rates are stored in the fx_rate table. Each record contains the conversion rate from a given currency to the Euro

I am not using reference currency which is by default USD. I am not calling fx_rate table or taking reference currency from fx_price

It is just a field with type currency.

 

SaschaWildgrube
ServiceNow Employee
ServiceNow Employee

DevTools is a scoped application with many helpful scripts ready to be re-used.

The built-in currency conversion API object (GlideCurrencyConverter) is a bit tricky to use.

Here you can find a nice wrapper function for currency conversion based on the ServiceNow OOTB functionality:

https://github.com/saschawildgrube/servicenow-devtools/blob/master/update/sys_script_include_6f29745...