USD to EURO conversion using transform map script for Import set API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2024 12:10 AM
I have a target table field (budget_cost) and source table field (u_budgetvalue) and i want to convert amount coming from third party using import set API and for that am using transform map, please suggest a correct script for currency (USD to EURO) conversion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2024 01:16 AM
Hi @kaduapoorva,
can you please use onBefore transform script and let me know whether it is useful or not.
Thanks
SP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2024 02:17 AM
Hello SP,
I have below concerns can you please help with updated code by considering below points
1) With above code am unable to get the converted amount from source table to target table. It is taking same amount which am sending in REST API explorer
2) For currency updates, am using fx_rate table where daily currencies are getting updated so we don't need to give fix conversion rate.
Thanks,
Apoorva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2024 01:23 AM
You will need to connect to some kind of API to fetch the current conversion rate. This may work for example: open.er-api.com/v6/latest/USD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2024 01:46 AM
Hello @kaduapoorva ,
Please check out this 2 below linbks which will be helpful.
We have OOB table the currency conversion is stored fx_rate with it you can solve your problem.
Also you can use the OOB API var conv = new sn_currency.GlideCurrencyConverter()
https://www.servicenow.com/community/grc-forum/rate-conversion-table/m-p/2447689
https://www.servicenow.com/community/developer-forum/currency-conversion-to-usd/m-p/1866905
Thank you,
Omkar