require(['N/search'], function(SEARCHMODULE){
var savedSearchId = 'customsearch_mySavedSearch';
var mySearch = SEARCHMODULE.load(savedSearchId);
var resultset = mySearch.run();
var results = resultset.getRange(0, 1000);
for(var i in results){
var result = results[i]...
// Assuming N/search is imported as `s`
var mySalesOrderSearch = s.create({
type: 'salesorder'
// Use the summary property of a Column to perform grouping/summarizing
columns: [{
name: 'salesrep',
summary: s.Summary.GROUP
},{
name: 'internalid',
...