Question re: governance that isn't clear from docu...
# suitescript
a
Question re: governance that isn't clear from documentation. Can test this but wanted to check in case anyone here knew off-hand before I do. When calling
search.run().each()
, NetSuite states that the
each()
function uses 10 units of governance. Is this only called once per search, regardless of the number of results? Or, does it use 10 units of governance per search result returned (aka every time it enters the callback function)? Another way of asking is, does the same amount of governance get used regardless of how many results are in a search?
e
It's once per search, I'm 99% sure (almost never 100% with NS 😉 ). The callback function you provide is what's being invoked on each result, not
each()
itself
☝️ 1
a
it will only loop 4k search results though i think? so if its more than that you'll have to do some more work
☝️ 1
e
A grossly oversimplified implementation of
each()
probably looks like
Copy code
const each = (callback) => {
  const results = doInternalSearchStuff() // This consumes the governance
  results.forEach(callback)
}
a
right on - thanks guys
2
c
You can test this if you want and get the remaining script usage before and after the code runs and see exactly how much it took.
👍 1