【问题标题】:NetSuite: Using SUITESCRIPT 1.0 inside of SUITESCRIPT 2.0NetSuite:在 SUITESCRIPT 2.0 中使用 SUITESCRIPT 1.0
【发布时间】:2018-11-25 04:50:17
【问题描述】:

是否可以在 SS2.0 文件中使用 SS1.0?是否有一些我必须添加的注释,或者甚至可能?

【问题讨论】:

  • 我不相信这是可能的。您可能可以通过调用window.nlapiGetFieldValue 或类似的方式在客户端脚本中摆脱它。我还没有测试过。更重要的问题是,你为什么要这样做?
  • 你是对的,我不想这样做,但是如果没有启用高级编号库存管理,你就不能使用 SS2.0 子列表 API,这家公司没有。没有它就行不通。不过谢谢你的回复
  • 可能是您想要向 NetSuite 支持报告的内容

标签: javascript netsuite suitescript


【解决方案1】:

这是不允许的。请参阅以下 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 方法和对象被封装在各种模块中。

【讨论】:

    【解决方案2】:

    我们有一个脚本,它需要用许多子列表项更新机会上的许多字段。使用我们的脚本,选择每个子列表项然后调用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
        })
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      相关资源
      最近更新 更多