- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 07:28 AM
Hi, I'm using the script below to get total cost of a event, considering the system default currency (USD), but the exchange rates aren't updated.
How can I get this rates updated?
var totalCost = Class.create();
totalCost.prototype = {
initialize: function(mrkevent) {
this.mrkevent = mrkevent;
},
getCost: function() {
var cost = 0;
//Get the total cost of all equipment for this event
var equipment = new GlideRecord('x_73586_marketing_equipment_request');
equipment.addQuery('marketing_event', this.mrkevent);
equipment.query();
while(equipment.next()){
cost = cost + parseFloat(equipment.cost.getSessionValue());
}
return cost;
},
type: 'totalCost'
};
Thanks!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 07:37 AM
Hi Sérgio,
Exchange rates are updated nightly by a scheduled job.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 07:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 08:09 AM
And if i want to update when any record is inserted at any table of my Application?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 09:11 AM
You can write a business rule that uses the same script as the scheduled job and run it to get the latest exchange rates. I would weigh the cost of frequent visits to the currency exchange against the need to refresh more than once a day. You might want to consider just updating the scheduled job to run ever couple hours.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2022 02:48 AM
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: