Netsuite 定义Suitescript 2.1的语法:添加'后无法评估脚本;N/search';界定
已部署并正确运行以下脚本:Netsuite 定义Suitescript 2.1的语法:添加'后无法评估脚本;N/search';界定,netsuite,suitescript,Netsuite,Suitescript,已部署并正确运行以下脚本: /** * @NApiVersion 2.1 * @NScriptType ClientScript * @NModuleScope SameAccount */ define([], function() { const lineFieldLookup = [ 'custcol_sas_adapter', 'custcol_sas_body', 'custcol_sas_box', 'custcol_sas_endcap',
/**
* @NApiVersion 2.1
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define([],
function() {
const lineFieldLookup = [
'custcol_sas_adapter', 'custcol_sas_body', 'custcol_sas_box', 'custcol_sas_endcap',
'custcol_sas_lidcap', 'custcol_sas_mortrclr', 'custcol_sas_snout', 'custcol_sas_strmclr',
'custcol_sas_topclamp', 'custcol_sas_tplate'];
function validateLine(scriptContext) {
const fieldValuesTable = lineFieldLookup.map((fieldId) => {
return ({
fieldId: fieldId,
value: scriptContext.currentRecord.getCurrentSublistValue({sublistId:'item', fieldId: fieldId })
})
});
console.log(fieldValuesTable)
}
return {
validateLine: validateLine,
};
});
但是,通过浏览器“编辑”并单击“保存”向脚本添加'N/search'
依赖项会引发错误
更新代码:
define(['N/search'],
function(search) {
// nothing changed here
}
错误:
Fail to evaluate script: {"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"","stack":[]}
什么使我无法添加搜索依赖项?我认为是时候学习
N/query
;)
作为客户端脚本,您可以使用require
加载N/search
/**
* @NApiVersion 2.1
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define([],
function () {
function loadSearch(callback) { require(['N/search'], search => { callback(null, search); }); }
function pageInit(context) {
try {
loadSearch((error, search) => {
if (!error) {
let c_data = search.lookupFields({
type: search.Type.CUSTOMER,
id: "4390463",
columns: ["altname", "email", "address"]
});
console.log('c_data', c_data);
}
});
} catch (e) {
console.error('loadSearch', e);
}
}
return {
pageInit: pageInit
};
});
我会为这件事向NS提供支持。我在我的帐户中遇到了同样的问题,我在中看到其他人谈论这个问题,我也遇到了同样的问题,这对我很有效:编辑脚本将“2.1”更改为“2.0”或“2.x”,添加所需的模块,保存脚本,编辑脚本将更改回“2.1”。不知道为什么;但我很高兴它做到了@很遗憾,这对我不起作用。请通过下面的fullstack.studio检查答案。那家公司为我解决了这个问题。我仍然在寻找官方文档,其中列出了需要使用require vs define导入的模块。感谢您推荐查询模块。但是,为了避免开发人员在寻找关于2.1脚本上“N/search”模块导入问题的答案时产生混淆,请从您的帖子中删除“query”,我将接受此作为答案。另外,是否有文档指定需要使用2.1脚本中的
require
vsdefine
导入哪些模块?您好,我从define;)中删除了N/query。我认为没有这样一个列表(require vs define)。'“require”可用于服务器端和客户端。当模块或脚本可用时,它将加载它。”“定义”用作在SuiteScript 2.x中创建入口点脚本和自定义模块的函数。我认为N/搜索很快就会被弃用:)。