[英]NetSuite: Using SUITESCRIPT 1.0 inside of SUITESCRIPT 2.0
是否可以在SS2.0文件中使用SS1.0? 是否需要添加一些注釋,或者甚至可以?
那是不允許的。 請參閱下面的SuiteAnswers摘錄。
https://netsuite.custhelp.com/app/answers/detail/a_id/44630
SuiteScript 2.0 –入門
版本同居規則
您的腳本(入口點腳本和支持庫腳本)必須使用SuiteScript 1.0或SuiteScript 2.0。 您不能在一個腳本中同時使用兩個版本的API。
但是,您可以有多個使用不同SuiteScript版本的腳本。 可以將它們部署在同一帳戶,同一SuiteApp和同一記錄中。
https://netsuite.custhelp.com/app/answers/detail/a_id/31709/kw/Suitescript%202.0
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方法和對象封裝在各種模塊中。
我們有一個腳本,該腳本需要使用許多子列表項來更新商機上的許多字段。 使用我們的腳本,選擇每個子列表項然后調用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
})
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.