Hi, I'm trying to run a search, but query.run().ea...
# suitescript
g
Hi, I'm trying to run a search, but query.run().each(function (row) { ... }); only contains 1 row result, where I expect it to iterate 500+ times. This is for a item search, has anyone encountered this issue before, or know what to do? Thanks,
b
if this is your first time using one of NetSuite's iterators, then you need to return a boolean in your each callback
g
Oh right! So like: rows.forEach(function(row) { names.push(row.getValue('displayname')); return true; });
b
yes
g
Awesome thank you, I'll check the MDN as to why, unless you want to say? Hehe
b
though a more careful function would do something other than return true if you get more than 4000 rows
NetSuite's iterator is similar to javascript iterators, though not quite the same
g
Cool as. Mmm, would be careful be like, counting how many we've iterated through so far? If it's to many (governance reasons or?) then exit out of the iterator, or?
b
return true over 4000 times and you get an error
g
Ha! Goodo, good heads up thanks
s
Also, this has nothing to do with MDN - SuiteScript API is it's own beast with its own (largely Java influenced, rather than javascript) style.
g
Oh goodo, thank you for letting me know