繁体   English   中英

NetSuite:在SUITESCRIPT 2.0中使用SUITESCRIPT 1.0

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM