Nour Khaled
05/01/2025, 11:14 PMCeligo AI
05/01/2025, 11:14 PMAI generated answer (using internal Slack threads):The error
SSS_SEARCH_FOR_EACH_LIMIT_EXCEEDED
is thrown when a SuiteScript tries to return more than 4000 search results at a time using the nlobjSearchResultSet.forEach
method. This is a limitation set by NetSuite to prevent excessive memory usage.
To overcome this limitation, you can use the Search.runPaged
method instead. This method allows you to retrieve search results in a paged manner, which is more efficient and avoids the 4000 results limit. Here is an example of how to use it:
javascript
var searchObj = search.load({
id: "customsearch_1",
});
var list = [];
var page;
var pagedData;
var additionalFilterExpression = [
["isinactive", "is", "F"],
"AND",
["subsidiary", "anyof", params.subsidiaries],
"AND",
["date", "before", searchDate],
];
if (params.department) {
additionalFilterExpression.push("AND");
additionalFilterExpression.push(["department", "is", params.department]);
}
if (params.class) {
additionalFilterExpression.push("AND");
additionalFilterExpression.push(["class", "is", params.class]);
}
if (params.location) {
additionalFilterExpression.push("AND");
additionalFilterExpression.push(["location", "is", params.location]);
}
searchObj.filterExpression = searchObj.filterExpression.concat(additionalFilterExpression);
pagedData = searchObj.runPaged({pageSize: 1000});
pagedData.pageRanges.forEach(function(pageRange) {
page = pagedData.fetch({index: pageRange.index});
page.data.forEach(function(row) {
list.push({
a:row.getValue(''),
})
return true;
});
return true;
});
In this example, the search results are retrieved in pages of 1000 results at a time, which is well below the 4000 results limit.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
05/01/2025, 11:14 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.890166521
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.888014436
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.876071334
Celigo AI
05/01/2025, 11:14 PM