If I recall correctly nlapiSearchRecord returns null when there are no results, so you'll usually have to this
Copy code
var results = nlapiSearchRecord(...);
if (!results) {
// special case when there are no results
return;
}
// you can now access results safely
for(var i = 0; i < results.length; i++) {
// ..
}