您将使用交易搜索而不是客户搜索来检索此信息。
// 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);
如果记录浏览器中未列出子列表或记录,则可能无法编写脚本 - 至少不能通过任何官方支持的方法。