MoCheeks
07/14/2022, 9:00 PMlet woLookup = search.lookupFields({
type: search.Type.WORK_ORDER,
id: wo_internalId,
columns: [
'bom.internalid',
'item',
'entity',
'custbody_ship_by_date_wo',
'createdfrom',
]
});
let salesOrd = woLookup.createdfrom[0].value;
When there is no 'createdfrom', I get an undefined error. Specifically: "Cannot read property 'value' of undefined".
Can't seem to get around that no matter what I try.
Any thoughts?Marvin
07/14/2022, 9:34 PMlet salesOrd = woLookup.createdfrom.length > 0 ? woLookup.createdfrom[0].value : null;
MoCheeks
07/14/2022, 9:40 PMNElliott
07/15/2022, 9:47 AMwoLookup.hasOwnProperty("createdfrom")...
or maybe:
woLookup.createdfrom[0].value||null;
Diderik
07/15/2022, 11:26 AMlet salesOrd = woLookup.createdfrom[0]?.value;
In case the createdfrom field is empty salesOrd
will be undefinedSandii
07/15/2022, 3:19 PM