javascript - N/currentRecord module does not exist when uploading User Event script to NetSuite (SuiteScript 2.0) -
i trying upload below script netsuite in order currency conversion purchase order currency usd.
i custom field updated usd amount whenever user keys in items purchase order.
when upload script, receive following error message:
fail evaluate script: {"type":"error.suitescriptmoduleloadererror","name":"module_does_not_exist","message":"module not exist: n/currentrecord.js","stack":[]}**
would appreciate 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(); });
in user events, not need currentrecord
module. rather, can retrieve record in context parameter netsuite passes event handler function:
function beforesubmit(context) { var transaction_currency = context.newrecord.getvalue({fieldid: "currency"}); var tx_currency_total = context.newrecord.getvalue({fieldid: "total"}); // etc }
Comments
Post a Comment