How to convert currency?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:06 AM
Can anyone help me to convert currency? We have editable currency fields called "Annual Maintenance Cost" and "Annual Maintenance Cost (Ref). When a user update the "Annual Maintenance Cost" with their currency, I'd like to know the amount in JPY. I configured one business rule below. However, it seems not working. I expected "JPY; 110,000,000" for "USD; 1,000,000" but the return value was "JPY; 9,090.9091" as shown in the attachment.
# Business Rule
- Timing
Before Update or Insert
- Code
(function executeRule(current, previous /*null when async*/) {
var value = parseFloat(current.u_maintenance.getReferenceValue());
current.u_is_related = current.u_is_related.getReferenceCurrencyCode() + ';' + value;
})(current, previous);
- Labels:
-
Project Portfolio Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:09 AM
Hi Masaya,
Refer the below links may helpful to you.
Scripting Currency and Price Fields - ServiceNow Wiki
I want to convert currency field
ServiceNow Commnunity MVP -2018 class.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 05:40 AM
Hi Karthik and Harshvardhan,
Thank you for your references. They must work for me but I found that my exchange rate was incorrect. After fixing the exchange rate, my code works fine.
On the other hand, do you know how can I get a value with a budget reference rate? When I using "getReferenceValue", it returns a number with a exchange rate. But it is easy for us to control a budget reference rate.
Best Regards,
Masaya Takeda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2020 03:13 AM
How did u fix the exchange rate?