I have an export from NetSuite that is setup to pull all the items from the item database. In the sandbox, there are about 140k items in total. My "preSavePage" hook filters out some of the items such as UPC Codes with alpha-numeric characters and with a total length of over 14 positions. This reduces the total number of items to about 120k. I have taken the same script and downloaded the NetSuite saved search (same as in the export) csv file and run this exact same script and it returns around the 120k mark of items. I also have the export setup to batch size and page size set to 1,000 (and reduced it to 500 and it processed slightly more records). The script runs with no errors. But it stops or "completes" at about 33 pages at the 1,000 page size and 98 at the 500 page size. All of the items are correctly moved over to the import and processed properly.
I get no page size errors or any other errors when the flow runs. It just completes without getting all the records. Here is the javascript routine that "filters" the item records coming in:
const regex = /[a-zA-Z\'\s+]/;
let lastUPC=' ';
let items = [];
let coitems = [];
let zero = "0";
let upcremoved = 0;
let toobig = 0;
let dups = 0;
for (let i=0; i < options.data.length; i++){
// NaN test
if(regex.test(options.data[i]['UPC Code'])){
console.log(options.data[i]['UPC Code']);
options.data.splice(i,1);
upcremoved ++;
continue;
}
if (options.data[i]['UPC Code'] > 99999999999999){ //14 digits are under
options.data.splice(i,1);
toobig ++;
continue;
}
if(i>0){
if (options.data[i]['UPC Code'] === lastUPC){ // compare for duplicate
options.data.splice(i,1);
dups ++;
continue;
}
}
items.push(options.data[i]);
lastUPC = options.data[i]['UPC Code'];
}
console.log('Char UPC removed ' + upcremoved);
console.log('Big UPC removed ' + toobig);
console.log('Dupe UPC removed ' + dups);
This leaves an array of records that is handed off to the formatting for the outgoing API call in the import section. There are no errors in the import process and the final database has all the items that have been processed. I capture the incoming stream from NetSuite and it is pulling them correctly... it's like it just doesn't finish! Anyone with some suggestions would be greatly appreciated.