Question: I am looking up the location on a sales ...
# suitescript
m
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
log
soLookup
when it has a value
m
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 })
e
if (soLookup.location?.length)
1
m
That was it dude!!!!! Thank you so much!
👍 1