【问题标题】:Work with sublist on record that isn't listed in record browser使用记录浏览器中未列出的记录子列表
【发布时间】:2017-04-07 18:09:50
【问题描述】:

我正在尝试处理客户记录中的交易列表。

当我运行 record.getSublists(); 时,子列表会显示 id 为 finhist

但是,我无法通过调用 record.getSublist('finhist'); 来处理此子列表,我假设这是因为该子列表未在 NetSuite 记录浏览器中列出客户记录。

在过去的question 中,有一个使用搜索模块的解决方法。我似乎无法建立另一个搜索来确定我想要的信息,所以我真正的问题是搜索模块之外是否有一种方法可以处理记录浏览器中未列出的子列表。

如果没有,那么我希望为客户获取给定类型的所有交易。所以所有销售订单或所有发票等。

【问题讨论】:

    标签: netsuite suitescript


    【解决方案1】:

    您将使用交易搜索而不是客户搜索来检索此信息。

    // 1.0
    function transactionsForCustomerByType(customerId, txType) {
        var filters = [
            ["mainline", "is", "T"], "and",
            ["type", "anyOf", txType], "and",
            ["entity", "anyOf", customerId]
        ];
    
        var columns = [ /* Your search columns */ ];
    
        return nlapiSearchRecord("transaction", null, filters, columns) || [];
    }
    
    var invoices = transactionsForCustomerByType(1234, "invoice");
    
    // 2.0
    // N/search imported as `s`
    function transactionsForCustomerByType(customerId, txType) {
        var filters = [
            ["mainline", "is", "T"], "and",
            ["type", "anyOf", txType], "and",
            ["entity", "anyOf", customerId]
        ];
    
        var columns = [ /* Your search columns */ ];
    
    
        var search = s.create({
            "type": s.Type.TRANSACTION,
            "filters": filters,
            "columns": columns
        });
    
        return search.run().getRange({"start": 0, "end": 1000}) || [];
    }
    
    var invoices = transactionsForCustomerByType(1234, s.Type.INVOICE);
    

    如果记录浏览器中未列出子列表或记录,则可能无法编写脚本 - 至少不能通过任何官方支持的方法。

    【讨论】:

    • 您能否编辑以同时提供 2.0 版本的答案(我可以翻译,但供未来用户使用)? @erictgrubaugh
    • 感谢您的帮助。我认为应该是return search.run().getRange({ start: 0, end: 1 }); 而不是getResults
    • 是否可以在同一搜索中过滤多种类型。我正在过滤记录类型(字符串),并且根据文档,我正在寻找 ANY 运算符。但是,当我执行["recordtype", search.Operator.ANY, ["type1", "type2"]] 时,我只会收到该客户所有交易的列表。
    • 不确定ANY 是否可以在这里工作;我想你需要做["recordtype", IS, "type1"], 'OR', ["recordtype", IS, "type2"]]
    • 我确实尝试过这样做,但发生了两件事。首先,运行时间超过几分钟(通常是几秒钟)。其次,它只返回类型 1 的订单,而不返回类型 2。
    猜你喜欢
    • 1970-01-01
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多