Hi Guys, Kindly help me out here!!! Thanks!! I hav...
# suitescript
n
Hi Guys, Kindly help me out here!!! Thanks!! I have below code which pulls 1000 lines each time! and then goes for next 1000 after the 1st for loop ends and the do while loop runs 5 time so it runs for 5000 lines of data!! but I’m getting below error while running it: SSS_SEARCH_RESULT_LIMIT_EXCEEDED (No more than 1000 search results may be requested at one time from nlobjSearchResultSet.getResults()) getting this error for this below line:
Copy code
results = resultSet.getRange( { start: start, end: start+1000});
Copy code
var x = 5;

            do {
                

                     results = resultSet.getRange( { start: start, end: start+1000});

                     start = start+1000;

                     para = para+1000;

                for(var l = 0;l<results.length;l++){


                  var temp_obj = {};

                   var resultss = results[l];


                    var column_results = resultss.columns;

                  for (var m = 0; m < column_results.length; m++) {

                      var label = firstResult.columns[m].label;

                      //log.debug('colllllll label',label);

               
               if(resultss.getText(column_results[m]) == undefined || resultss.getText(column_results[m]) == null || resultss.getText(column_results[m]) == ""){

                
                temp_obj[label] = resultss.getValue(column_results[m]);


               }else{

                temp_obj[label] = resultss.getText(column_results[m]);


               }

             }

             response.results = response.results.concat(temp_obj);


            }


            --x;

            log.debug('searchResultCount',searchResultCount);
                   
                  
        } while (x>0);
c
Need more info. What script type is this for a start? - this makes a difference to what the solution is
n
@CD its a suitelet thanks for reply
b
your logic looks fine as long as you you set start to 0 at the beginning
otherwise, its basically always wrong to be using getRange
do a paged search instead
n
umm! okay I have put start as 0 !! reason i’m using range is I want to print some lines of data and then again rerun the script as if there are more than 15k line of data TIME LIMIT EXCEED error is coming so to avoid it i’m running 5k lines a time thats why I’m using getRange here!!
b
a paged search can do the same thing, while being faster and using less points
n
okay but what I don’t understand is why I’m getting this error:
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "SSS_SEARCH_RESULT_LIMIT_EXCEEDED",
  "message": "No more than 1000 search results may be requested at one time from nlobjSearchResultSet.getResults(). Please narrow your range, or use nlobjSearchResultSet.forEachResult() instead.",
  "stack": [
    "createError(N/error)",
    "onRequest(/SuiteScripts/SUT_REST_report.js:92)",
    "createError(N/error)"
  ],
  "cause": {
    "name": "SSS_SEARCH_RESULT_LIMIT_EXCEEDED",
    "message": "No more than 1000 search results may be requested at one time from nlobjSearchResultSet.getResults(). Please narrow your range, or use nlobjSearchResultSet.forEachResult() instead."
  },
  "id": "",
  "notifyOff": false,
  "userFacing": true
}
there are no more than 1000 lines or search results! so🤔
b
not enough code shared to really know
you can use a debugger to step through what each iteration of your loop looks like
n
okay sure
thanks
b
though i personally would just toss everything not related to x or the start variables
its a lot easier debugging small parts of your code
n
okays