currency.exchangeRate(options)
Method Description |
Method used to return the exchange rate between two currencies based on a certain date. The source currency is looked up relative to the target currency on the effective date. For example, if use British pounds for the source and US dollars for the target and the method returns '1.52’, this means that if you were to enter an invoice today for a GBP customer in your USD subsidiary, the rate would be 1.52. The exchange rate values are sourced from the Currency Exchange Rate record.
Note:
The Currency Exchange Rate record itself is not a scriptable record. Only base currencies can be converted. The target must be a base currency in your NetSuite account. If not, inaccurate values are returned. For details, see Setting a Base Currency. |
Returns |
The exchange rate as a decimal number |
Supported Script Types |
Client and server scripts For additional information, see SuiteScript 2.x Script Types. |
Governance |
10 units |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
Date |
optional |
|
2015.2 |
|
number | string |
required |
|
2015.2 |
|
number | string |
required |
|
2015.2 |
Errors
Error Code |
Message |
Thrown If |
---|---|---|
|
exchangeRate: Missing a required argument: <source/target> |
The |
|
You have entered an invalid currency symbol or internal ID: <target/source> |
The If the Multiple Currencies feature is enabled, from your account, you can view a list of currency internal IDs and ISO codes at Lists > Accounting > Currencies. |
Syntax
The following code snippet shows the syntax for this member. It is not a functional example. For a complete script example, see N/currency Module Script Sample.
//Add additional code
...
var canadianAmount = 100;
var rate = currency.exchangeRate({
source: 'CAD',
target: 'USD',
date: new Date('7/28/2015')
});
var usdAmount = canadianAmount * rate;
...
//Add additional code