This is shortest, easiest and most commonly used method. Unfortunately, it has one major limitation - cannot be used on searches with more than 4000 results (rows).
// Assume that 'N/search' module is included as 'search'
var s = search.create({
type : search.Type.TRANSACTION,
columns : ['entity','amount'],
filters : [ ['mainline', 'is', 'T'],
'and', ['type', 'is', 'CustInvc'],
'and', ['status', 'is', 'open']
]
});
var resultSet = s.run();
// you can use "each" method on searches with up to 4000 results
resultSet.each( function(result) {
// you have the result row. use it like this....
var transId = result.id;
var entityId = result.getValue('entity');
var entityName = result.getText('entity');
var amount = result.getValue('amount');
// don't forget to return true, in order to continue the loop
return true;
});