I am using search.lookupFields to get the id's an...
# suitescript
c
I am using search.lookupFields to get the id's and text from my select list. But, I can't seem to pull any of the values and I feel as if I have tried everything. Any thoughts on what I am doing wrong?
Copy code
var fields = search.lookupFields({
   type: search.Type.VENDOR,
   id: vendorId,
   columns: ['myselectfield']
});
//fields looks like this [{"value":"3","text":"vCard"}]
 obj[0].text - but this doesn't work?
e
fields.myselectfield[0].value
check that myselectfield has a length too
c
I am doing a ``` Array.isArray(fields) && fields.length >=1
I'll give that a go
s
lookupFields returns an object, not an array?
e
Copy code
function getLookupSelectValue(type, id, column) {
                var fieldLookup = search.lookupFields({
                    type: type,
                    id: id,
                    columns: column
                });
                if (fieldLookup && fieldLookup[column] && fieldLookup[column].length > 0) {
                    return fieldLookup[column][0].value;
                }
                return null;
            }
💯 1
yeah
s
so @Carl Jenkins predicate should be false.
c
@stalbert Do you mean the value returned from getLookupSelectValue()?
Excellent! Thanks so much! Finally got this to work. Initially, I was forgetting to quote the column I was using
Copy code
fieldLookup[column]
instead of
Copy code
fieldLookup["column"]
, but all good now! Thanks so much.
s
FWIW, I meant your fragment
Array.isArray(fields) && fields.length >=1
👍 1