currency.exchangeRate(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

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

N/currency Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.date

Date

optional

  • Pass in a new Date object. For example, date: new Date('7/28/2015')

  • If date is not specified, then it defaults to today (the current date).

  • The date determines the exchange rate in effect. If there are multiple rates, it is the latest entry on that date.

  • Use the same date format as your NetSuite account.

2015.2

options.source

number | string

required

  • The internal ID or three-letter ISO code for the currency you are converting from.

  • For example, you can use either 1 (internal ID) or USD (currency code).

  • If the Multiple Currencies feature is enabled, from your account, you can view a list of all the currency internal IDs and ISO codes at Lists > Accounting > Currencies.

2015.2

options.target

number | string

required

  • The internal ID or three-letter ISO code for the currency you are converting to.

2015.2

Errors

Error Code

Message

Thrown If

MISSING_REQD_ARGUMENT

exchangeRate: Missing a required argument: <source/target>

The source or target argument is missing.

SSS_INVALID_CURRENCY_ID

You have entered an invalid currency symbol or internal ID: <target/source>

The source or target argument is invalid.

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
Important:

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 

        

Related Topics

N/currency Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices