Reputation: 873
I am trying to find out if I can pull a sublist without loading the main record. It seems wasteful when all I need is the sublist and I don't get the sublist back with a saved search. search.lookupFields only gives access to body fields which is so very close. I would like to pull a specific sublist is this possible? Thanks in advance for any help.
Upvotes: 2
Views: 1500
Reputation: 2069
Sublists in NetSuite are actually records which are linked through some field(like joins in SQL). Being said that, you can use join property in search.createFilter, search.createColumn, searchResult.getValue etc and pass the common field to it while the name parameter will contain the fieldId of the field that you want to fetch the value of. Eg to fetch item data from salesorder, you can run the following code
var salesOrderSearchResult = search.create({
type: 'transaction,
filters: search.createFilter({
name: 'internalid',
join: 'item',
operator: 'is',
values: ITEM_INTERNAL_ID
}),
columns: search.createColumn({ name: 'itemid', join: 'item' })
}).run().getRange({ start: 0, end: 100 });
// to fetch results
salesOrderSearchResult.forEach(function (searchResult) {
var itemId = searchResult.getValue({ name: 'itemId' ,join: 'item' });
})
Upvotes: 1