How to use Lookup in Suite Script 2.0 in Netsuite?
Hi All,
In this post I am going to write code about how to lookup in Suite Script 2.0.
In Netsuite Suite Script 1.0 it is very easy to do lookup using nlapiLookupField
but in Suite Script we have to use search module for this.
Below is the code for look up:
var fieldLookUp = search.lookupFields({
type: search.Type.CUSTOMER,
id: entityid,
columns: ['custentity2', 'custentity3']
});
var abc= fieldLookUp.custentity3;
var def= fieldLookUp.custentity2;
* We can add as many as we want in columns , basically columns is array of internalid from record which we are looking up .
** type is the type which we are using to look up. In case you want to look custom record then use
type: customrecord_name,
*** search is a module which we are passing in start of function and related variable also.
**** it return object and for multiselect array of object, so here in case if it is not multi select we can simply call fieldLookUp.custentity2. If this contains multiselect then you have to itterate through that .
Performs a search for one or more body fields on a record.
You can use joined-field lookups with this method, with the following syntax:
** Please check here for Select and Multi Select fields.
Please let us know if you have any better way to do this.
Thanks
Netsuite Guru
In this post I am going to write code about how to lookup in Suite Script 2.0.
In Netsuite Suite Script 1.0 it is very easy to do lookup using nlapiLookupField
but in Suite Script we have to use search module for this.
Below is the code for look up:
var fieldLookUp = search.lookupFields({
type: search.Type.CUSTOMER,
id: entityid,
columns: ['custentity2', 'custentity3']
});
var abc= fieldLookUp.custentity3;
var def= fieldLookUp.custentity2;
* We can add as many as we want in columns , basically columns is array of internalid from record which we are looking up .
** type is the type which we are using to look up. In case you want to look custom record then use
type: customrecord_name,
*** search is a module which we are passing in start of function and related variable also.
**** it return object and for multiselect array of object, so here in case if it is not multi select we can simply call fieldLookUp.custentity2. If this contains multiselect then you have to itterate through that .
Performs a search for one or more body fields on a record.
You can use joined-field lookups with this method, with the following syntax:
join_id.field_name
** Please check here for Select and Multi Select fields.
Please let us know if you have any better way to do this.
Thanks
Netsuite Guru
Comments
Post a Comment
Thanks for you message, please join us on Facebook and Linkedin