使用记录浏览器中未列出的记录子列表

时间:2017-04-07 18:09:50

标签: netsuite suitescript

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

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

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

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

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

1 个答案:

答案 0 :(得分:2)

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

// 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);

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