1
votes

I have a custom record in netsuite with several fields. One field is transaction date, another is Amount (number) and the third one is currency (USD, CAD, etc). I would like to calculate in another column the USD equivalent of the amount field based on the currency. For example 1/1/2016 CAD $1000 and from those three fields in the custom record, I would like to put the value in a fourth field that would convert the $1000 CAD to USD using the exchange rate for 1/1/2016. I have found the following API in NetSuite -- "nlapiExchangeRate(sourceCurrency, targetCurrency, effectiveDate) " but I cannot get it to work. Any ideas if this is possible? Thanks.

2
Can you share you code or snippet of the code - Rusty Shackles
Thanks - is it possible to use this function in a saved search or directly in a custom formula field? I am trying to take a value from a saved search and multiply it by nlapiExchangeRate('CAD','USD',01/01/2016') but I keep getting an ERROR: INVALID EXPRESSION. Thanks. - user5853237

2 Answers

1
votes

Suitescript API are not allowed in Saved Searches or Custom Formula Fields.

1
votes

I just tested this with the same example on the SuiteAnswers site (below) It worked fine for me. Make sure you are getting your values and trying to run the data after you are sure you ave everything.

var usdAmt=100.00;
var rate=nlapiExchangeRate('USD','CAD','01/01/2016');
var canAmt=usdAmt*rate;
nlapiLogExecution('DEBUG',rate+' / '+canAmt);

The link to that page, in case you don't have it, is:

nlapiExchangeRate(sourceCurrency, targetCurrency, effectiveDate)