Getting currency value and symbol via REST API

tt-jtw
Kilo Expert

I have a currency field on a table called Balance (u_balance).   When I get the contents of a table record via the REST, the u_balance field returns a numeric value which is value in USD (our default system currency).

For example, when the field contains 94.99 Singapore Dollars, the REST API returns 75.14.   No currency code accompanies this data.

Is there anyway to get the currency in other display formats. Similar to the getCurrencyDisplayValue() or getCurrencyStriing() methods listed in this wiki article:

Scripting Currency and Price Fields - ServiceNow Wiki

1 ACCEPTED SOLUTION

David OBrien
Kilo Guru

According to the knowledge article listed below, currency fields are always handled in US dollars via the REST API.   See #17 on the KB listed below.



ServiceNow KB: Table API FAQs (KB0534905)


View solution in original post

5 REPLIES 5

David OBrien
Kilo Guru

According to the knowledge article listed below, currency fields are always handled in US dollars via the REST API.   See #17 on the KB listed below.



ServiceNow KB: Table API FAQs (KB0534905)


Hi,



I would be great if there was a possibility to return prices in currency different from one that selected in user's profile... let's say taking culture from a request header.



Another issue with the current REST approach is when a user has his/her currency different from the fx_currency_instance currency for specific field value. In this case the latest currency rate is taken which is not correct 'cause the record may have been created a long time ago and the currency rate was different.



Regards,


Andrii


This answer is not correct at least in Jakarta. The returned value is in the currency of the requestor, not in USD. So if your external System needs to query values in EUR, you can create a WebService-User for that system and set the its location to Germany, French, Belgium or something like that



Quote from the same link you posted:



When performing a REST request, returned currency values are converted to the local currency based on the user's Locale. When inserting data, no conversion is performed. This behavior applies to fields of the types Currency or Price.


For example, if a user in the UK locale queries records with currency values in USD, the returned values are converted to GBP. However, if this user adds a new record with the currency field value in GBP, the value is stored in GBP without being converted to USD. This GBP value will be displayed in USD if queried by a user in the US locale.


kikhtenko
Kilo Contributor

Frankly speaking this is now a good approach due to security concerns. You will need to store WebService-User login and password somewhere. And you will need to create a new user per each currency.


Our solution was to not to use Table API for currency fields and replace it either Scripted REST API or processors and handle currencies using our script includes, taking correct conversion rate rather than default SNow approach.