Javascript NetSuite:在SUITESCRIPT 2.0中使用SUITESCRIPT 1.0
是否可以在SS2.0文件中使用SS1.0?是否有一些注释我必须添加或甚至可能添加?这是不允许的。请参阅以下SuiteAnswers的摘录。Javascript NetSuite:在SUITESCRIPT 2.0中使用SUITESCRIPT 1.0,javascript,netsuite,suitescript,Javascript,Netsuite,Suitescript,是否可以在SS2.0文件中使用SS1.0?是否有一些注释我必须添加或甚至可能添加?这是不允许的。请参阅以下SuiteAnswers的摘录。 SuiteScript 2.0–入门 版本同居规则 您的脚本(入口点脚本和支持库脚本)必须使用SuiteScript 1.0或SuiteScript 2.0。不能在一个脚本中同时使用两个版本的API。 但是,您可以有多个使用不同SuiteScript版本的脚本。这些可以部署在同一帐户、同一SuiteApp和同一记录中 2016版第1版(201
SuiteScript 2.0–入门 版本同居规则
您的脚本(入口点脚本和支持库脚本)必须使用SuiteScript 1.0或SuiteScript 2.0。不能在一个脚本中同时使用两个版本的API。
但是,您可以有多个使用不同SuiteScript版本的脚本。这些可以部署在同一帐户、同一SuiteApp和同一记录中
2016版第1版(2016.1)发行说明 nlapi/nlobj前缀失效
SuiteScript2.0的造型和行为与现代JavaScript相似。为了实现这一目标,SuiteScript2.0方法和对象没有以nlapi和nlobj作为前缀。
这一变化也反映了SuiteScript 2.0的模块化组织。SuiteScript 1.0方法和对象分别属于nlapi和nlobj名称空间。SuiteScript2.0方法和对象封装在各个模块中。我们有一个脚本,需要使用许多子列表项更新Opportunity上的许多字段。在我们的脚本中,选择每个子列表项然后调用
setCurrentSublistValue()
的2.0方法花费了大约40秒来执行59个子列表项。我使用了window.nlapiSetLineItemValue()
hack,大约需要2秒钟
这可能不是推荐的和YMMV,但我做了一些检查,看看是否会工作。请参阅下面我的代码
var canUseLegacyApi = typeof window.nlapiSetLineItemValue === "function";
// Loop the sublist and update
for (var k = 0; (itemCount >= 0) && (k < itemCount); k++) {
if (!canUseLegacyApi) { // If the Suite Script 1.0 API isn't available, do it the slow way.
currentRecordOpp.selectLine({
sublistId: 'item',
line: k
})
}
if(canUseLegacyApi) {
// TODO: HACK: Change this total hack once SS2.x supports updating line item values (without doing a
// selectLine, which takes too long)
// NOTE: SS1.0 sub-list calls are 1-based vs SS2.x calls being 0-based. Hence the k+1
window.nlapiSetLineItemValue('item', 'field_id, k+1, 'new value');
// Update other fields here...
} else {
currentRecordOpp.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'field_id',
value: 'new value',
fireSlavingSync: true
});
// Update other fields here...
}
if(!canUseLegacyApi) {
currentRecordOpp.commitLine({sublistId: 'item'});
}
// TODO: HACK: This is required to re-paint the sublist after the nlapiSetLineItemValue calls. Remove once SS2.x
// supports this.
currentRecordOpp.selectLine({
sublistId: HVAC_SUBLIST,
line: 0
})
}
var canUseLegacyApi=typeof window.nlapiSetLineItemValue==“函数”;
//循环子列表并更新
对于(var k=0;(itemCount>=0)和&(k
我认为这是不可能的。您可以在客户端脚本中通过调用window.nlapiGetFieldValue
或类似的方法来解决这个问题。我还没有测试过。更重要的问题是,你为什么要这样做?你是对的,我不想这样做,但是如果没有启用Advanced Number Inventory Management,你就不能使用SS2.0子列表api,而这家公司没有启用。没有它就不能工作。感谢您的回复,但您可能需要向NetSuite支持部门报告某些情况