How do y'all handle undefined values from a search...
# suitescript
j
How do y'all handle undefined values from a search.lookUpFields? I'm currently using (as an example):
Copy code
let appDiscount;
if (customerLookUp.custentity_apsw_builder_app_discount.value) {
                        appDiscount = customerLookUp.custentity_apsw_builder_app_discount[0].value;
                    }
But it seems clunky just because I'll have to do it on a bunch of fields. Anyone know of an easier way?
d
if you are using suitescript 2.1, could consider using some variation of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
j
Using a ternary is working now - thank you!