I am trying to upload the below script to NetSuite in order to do a currency conversion from the purchase order currency to USD.
I would like a custom field to be updated with the USD amount whenever a user keys in any items into a purchase order.
When I upload the script, I receive the following error message:
Fail to evaluate script: {"type":"error.SuiteScriptModuleLoaderError","name":"MODULE_DOES_NOT_EXIST","message":"Module does not exist: N/currentRecord.js","stack":[]}**
Would greatly appreciate some guidance. Thank you.
/**
*@NApiVersion 2.x
*@NModuleScope Public
*@NScriptType UserEventScript
*/
define(['N/currency', 'N/currentRecord'],function(currency, currentRecord) {
function POCurrencyConversion() {
var Fixed_Currency = 'USD';
var Transaction_Currency = currentRecord.getValue('currency');
var Tx_currency_total = currentRecord.getValue('total');
var rate = currency.exchangeRate({
source: Transaction_Currency,
target: Fixed_Currency
});
var ConvertedAmount = Tx_currency_total * rate;
currentRecord.setValue('custbody_po_total_usd',ConvertedAmount)
}
POCurrencyConversion();
});