简体   繁体   English

将用户事件脚本上载到NetSuite(SuiteScript 2.0)时,不存在N / currentRecord模块

[英]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.

相关问题 在 SuiteScript 2.0 中使用 N/Cache 模块 - Using the N/Cache Module in SuiteScript 2.0 NetSuite:TypeError:log.debug 不是客户端脚本 (SuiteScript 2.0) 中的函数 - NetSuite: TypeError: log.debug is not a function in Client Script (SuiteScript 2.0) 如何使用 SuiteScript 2.0 重新安排 Netsuite 中的调度脚本 - How to Reschedule the Schedule Script in Netsuite using SuiteScript 2.0 version NetSuite:在SUITESCRIPT 2.0中使用SUITESCRIPT 1.0 - NetSuite: Using SUITESCRIPT 1.0 inside of SUITESCRIPT 2.0 使用自定义模块创建 NetSuite 脚本时出现“执行定义回调时所有 SuiteScript API 模块不可用” - Getting “All SuiteScript API Modules are unavailable while executing your define callback” When Creating NetSuite Script With Custom Module 无法在 SuiteScript 2.0 N/query 模块中加载工作簿 - Cannnot Load Workbook in SuiteScript 2.0 N/query Module SuiteScript 2.0 中的自定义模块 - Custom Module in SuiteScript 2.0 如何在netsuite上使用用户事件套件脚本更新不支持的交易类型(例如,账单)上的字段 - How can I update fields on unsupported transaction types such as Bill with user event suitescript on netsuite Chrome异常中的调试脚本Netsuite suitescript - Debugging script Netsuite suitescript in Chrome exception SuiteScript; 用户事件脚本中的异步HTTP请求 - SuiteScript; Asynchronous HTTP request inside of user event script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM