how many governance need for search.run().each() p...
# ask-stanley-ai
c
how many governance need for search.run().each() per record?
c
AI generated answer (using internal Slack threads):
The
search.run().each()
function in NetSuite SuiteScript uses 10 units of governance per search, not per record. This means that regardless of the number of results returned by the search, the
each()
function will only consume 10 units of governance. However, it's important to note that the
each()
function will only loop through a maximum of 4000 search results. If your search returns more than 4000 results, you will need to implement additional logic to handle the remaining results. Here's a simplified example of how the
each()
function might be implemented:
Copy code
javascript
const each = (callback) => {
  const results = doInternalSearchStuff() // This consumes the 10 units of governance
  results.forEach(callback)
}
In this example,
doInternalSearchStuff()
represents the internal workings of the
each()
function, which consumes the 10 units of governance. The
callback
function is then invoked for each result in the
results
array. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.862177551
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834547043
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834317386
Please provide your feedback on this answer.