i've got a schedule script in SS1.0 running a sear...
# suitescript
p
i've got a schedule script in SS1.0 running a search on the following
var result = nlapiSearchRecord('customrecord_gc_otif_if_variances', null, filters, columns);
search works fine, however I'm having difficulties when there are no records found. Result outputs as an empty string if you log it, typeof shows it as an object, trying to do result.length tells me it is null, but checking if result === null returns false. any ideas?
b
the first 3 things you mentioned are the usual characteristics of null
how are you comparing its value to null?
p
so far, looked at result === null and also Object.keys(result).length === 0;
b
by looked at you mean something like
Copy code
nlapiLogExecution('DEBUG', '=== null', result === null)
or something else?
p
if(result === null) {return;} prior to processing the result. going to give everything a second look over, been one of those mornings
b
honestly that should return
you can be paranoid and do
Copy code
if (!result || !result.length) {
  return;
}
i liked to use
Copy code
var result =
  nlapiSearchRecord(
    "customrecord_gc_otif_if_variances",
    null,
    filters,
    columns
  ) || [];
to force the search results to be an array for consistency
p
that one has worked now, how strange!
Thanks for the assistance again!