Reputation: 187
I am trying to work with the list of transactions on a customer record.
When I run record.getSublists();
the sublist shows up with id of finhist
However, I can not work with this sublist by calling record.getSublist('finhist');
I'm assuming this is because the sublist is not listed in the NetSuite record browser for Customer records.
In a past question there was a workaround for it using the search module. I can't seem to build another search to ascertain the info I want, so my real question is if there is a way outside of the search module to work with sublists that aren't listed in the record browser.
If there isn't, then I am looking to get all transactions of a given type for a customer. So all Sales Orders or all Invoices, etc.
Upvotes: 1
Views: 576
Reputation: 8847
You would retrieve this information using a Transaction search rather than a Customer search.
// 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);
If a sublist or a record is not listed in the Record Browser, then it is likely not scriptable - at least not via any officially supported method.
Upvotes: 2