In SuiteScript, I am attempting to run a saved search but I got an error "Cannot read property 'length' from null" . See my code :
if(search.length>0){
layout += '<tr height="1cm">';
layout += '</tr>';
layout += '<tr>';
layout += '<td align="right" border="0px" colspan="8" style=\"font-size:12px;\">';
for(var x = 0;x<search.length;x++){
layout += iE(search[x].getText('account'))+'<br/>';
}
layout += '</td>';
}
also I tried this code also but same result.
if(search!==null %% search.length!==null){
layout += '<tr height="1cm">';
layout += '</tr>';
layout += '<tr>';
layout += '<td align="right" border="0px" colspan="8" style=\"font-size:12px;\">';
for(var x = 0;x<search.length;x++){
layout += iE(search[x].getText('account'))+'<br/>';
}
layout += '</td>';
}