1
votes

I have a large nlobjSearchResultSet object with over 18,000 "results".

Each result is a pricing record for a customer. There may be multiple records for a single customer.

As 18000+ records is costly in governance points to do mass changes, I'm migrating to a parent (customer) record and child records (items) so I can make changes to the item pricing as a sublist.

As part of this migration, is there a simple command to select only the nlapiSearchResult objects within the big object, which match certain criteria (ie. the customer id).

This would allow me to migrate the data with only the one search, then only subsequent create/saves of the new record format.

IN a related manner, is there a simple function call to return to number of records contained in a given netsuite record? For % progress context.

Thanks in advance.

2

2 Answers

2
votes

you can actually get the number of rows by running the search with an added aggregate column. A generic way to do this for a saved search that doesn't have any aggregate columns is shown below:

var res = nlapiSearchRecord('salesorder', 'customsearch29', null, 
    [new nlobjSearchColumn('formulanumeric', null, 'sum').setFormula('1')]);
var rowCount = res[0].getValue('formulanumeric', null, 'sum');
console.log(rowCount);
0
votes

To get the total number of records, the only way is do a saved search, an ideal way to do such search is using nlobjSearch

Below is a sample code for getting infinite search Results and number of records

var search = nlapiLoadSearch(null, SAVED_SEARCH_ID).runSearch();
var res = [],
    currentRes;

var i = 0;

while(i % 1000 === 0){
  currentRes = (search.getResults(i, i+1000) || []);
  res = res.concat(currentRes );
  i = i + currentRes.length;
}

res.length or i will give you the total number of records and res will give you all the results.