Question: I am looking up the location on a sales order from a PO createdfrom id:
var soLookup = search.lookupFields({
type: search.Type.SALES_ORDER,
id: relatedSo,
columns: ‘location’
});
I expect most of the time for the location to be empty. I keep getting Cannot read property ‘value’ of undefined. How do I test for no results from the lookup? I want that to be a condition but I’m stuck.
e
ehcanadian
05/11/2023, 6:53 PM
log
soLookup
when it has a value
m
Michael McNamara
05/11/2023, 6:54 PM
Yeah. I tried log but I still get that error:
var soLookup = search.lookupFields({
type: search.Type.SALES_ORDER,
id: relatedSo,
columns: ‘location’
});
if(soLookup){
var soloc = soLookup.location[0].value;
}
else{
var soloc = ‘Empty’;
}
log.debug({
title: “field data”,
details: ‘SO: ’ + relatedSo + ' PO Location: ' + poLocation + ' SO Location: ' + soloc
})