I'm doing some M/R testing and realizing I would l...
# suitescript
e
I'm doing some M/R testing and realizing I would love to be able to do:
Copy code
function getInputData() {
  return {
    type: "search",
    id: 123,
    limit: 10 // <= this!
  };
}
👍 3
e
So basically just get the first N records?
e
Right
Without having to run the search and slice the array myself
Could then be extended to something like
Copy code
limit: runtime.getCurrentScript().getParameter("custscript_record_limit")
e
+1
b
Copy code
function getInputData() {
  return search.load({
    type: "search",
    id: 123,
  }).run().getRange(0, 10);
}
e
Yeah I know how to do it manually like that
But it would be nice not to have to refactor my code for testing purposes
I don't want to run my M/R on tens of thousands of records for every change I make
so a simple limit like this would make that extremely simple
e
But you’d still be modifying code when testing vs production. Why not just let the saved search limit the number of records it returns? If you create a script parameter for the datasource which points to a saved search using List/Record you can point it to the production SS or the test SS to get the number of records your MR script needs.
e
Modifying code sure, but most likely never my `getInputData`; especially one so simple as that. Given the way I architect my code, once the entry points are in place, I almost never touch the primary script again. All my work is done in other custom modules. I shouldn't have to open my main script again. Using alternate Saved Searches as a script parameter is also an approach I take.
This way, however, facilitates an approach that does not require a secondary Deployment