是否可以在SS2.0文件中使用SS1.0?我是否需要添加一些注释,或者甚至有可能呢?
发布于 2016-05-21 11:20:22
这是不允许的。请看下面SuiteAnswers的摘录。
SuiteScript 2.0 -入门
版本同居规则
您的脚本(入口脚本和支持库脚本)必须使用SuiteScript 1.0或SuiteScript 2.0。不能在一个脚本中使用两个版本的API。
但是,您可以有多个使用不同SuiteScript版本的脚本。它们可以部署在相同的帐户、相同的SuiteApp和相同的记录中。
2016年版第1版(2016.1)发行说明
nlapi/nlobj前缀退休
SuiteScript 2.0建模是为了看起来和行为类似于现代JavaScript。为了实现这一目标,SuiteScript 2.0方法和对象不以nlapi和nlobj作为前缀。
这一变化还反映了SuiteScript 2.0的模块化组织。SuiteScript 1.0方法和对象分别属于nlapi和nlobj命名空间。SuiteScript 2.0方法和对象封装在不同的模块中。
发布于 2017-09-12 17:05:55
我们有一个脚本,需要更新许多字段的机会与许多子列表项目。使用我们的脚本,选择每个子列表项然后调用setCurrentSublistValue()的2.0方式花费了大约40秒的时间来完成59个子列表项。我使用了window.nlapiSetLineItemValue()黑客,它需要大约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
})
}https://stackoverflow.com/questions/37327247
复制相似问题