Search code examples
netsuitesuitescript

How to access the search LookupFields result


Below is my search code. I'm searching for the Invoice number by using the invoice internal ID.

What is the right way to access the lookupFields search result?

var invoiceNumber = fieldLookUp.value;

I'm using the above line but the "invoiceNumber" is empty. Thanks for your help.

var fieldLookUp = search.lookupFields({
                    type: search.Type.INVOICE,
                    id: invoiceId,
                    columns: 'tranid'
                });

                var invoiceNumber = fieldLookUp.value;

Solution

  • It would just be fieldLookUp.tranid. lookupFields returns an Object where the Object's keys are your Columns and the Object's values are the Column values.

    Check out this video for more details on Field Lookups in SS2.0: https://www.youtube.com/watch?v=_fs2thUdEmQ