[英]N/currentRecord module does not exist when uploading User Event script to NetSuite (SuiteScript 2.0)
I am trying to upload the below script to NetSuite in order to do a currency conversion from the purchase order currency to USD. 我正在尝试将以下脚本上传到NetSuite,以便从采购订单货币到美元进行货币转换。
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":[]}** 无法评估脚本:{“type”:“error.SuiteScriptModuleLoaderError”,“name”:“MODULE_DOES_NOT_EXIST”,“message”:“模块不存在: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();
});
In User Events, you do not need the currentRecord
module. 在用户事件中,您不需要currentRecord
模块。 Rather, you can retrieve the record in context from the parameter that NetSuite passes into your event handler function: 相反,您可以从NetSuite传递到事件处理函数的参数中检索上下文中的记录:
function beforeSubmit(context) {
var Transaction_Currency = context.newRecord.getValue({fieldId: "currency"});
var Tx_currency_total = context.newRecord.getValue({fieldId: "total"});
// etc
}
You cannot use "N/currentRecord" module in User Event Script. 您不能在用户事件脚本中使用“N / currentRecord”模块。 This module is supported in Client Script. 客户端脚本支持此模块。 instead you can make use of context.newRecord. 相反,你可以使用context.newRecord。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.