Hello, I have search in my script which doesn't wo...
# suitescript
k
Hello, I have search in my script which doesn't works because there are too many search results(over 15000).
b
in general if you run out of points, you need to use a scheduled or map reduce script
k
I am using map/reduce script at the moment
I wonder if you can help me to check governance in suitescript 2.x
m
What stage of the M/R? Are you using a paged search? What does "doesn't work"? If you can post the script might be easier to help
Using a paged search as per below I have a search working nicely with 50k results
Copy code
var pagedData = search
  .create( /* your search here */)
  .runPaged({ pageSize: 1000 });
	
pagedData.pageRanges.forEach(function (pageRange) {
  pagedData.fetch({ index: pageRange.index }).data.forEach(function (result) {
    /* each result returned here */
  });
});
b
in general you structure your script a certain way in a map/reduce script to avoid governance limits
k
@michoel your script shows me this msg
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "JS_EXCEPTION",
  "message": "org.mozilla.javascript.EcmaError: ReferenceError: \"pagedData\" is not defined. (/SuiteScripts/SSTX_MR_CreateInventorySnapshots.js#43)"
}
I've tried this way before but didn't find the solution for this error
m
Can you share your code?
k
Sorry, It was typos error Your script is working Great Thanks 🙂
👍