Thursday, November 15, 2018

Use nlapiLookupField() for joined fields

Use nlapiLookupField() for joined fields

The following example returns the customer email, contact email and contact entity id for a customer specified by the customer recordId. In this scenario, using a joined field lookup on the array "cust_fields" eliminates having to perform multiple nlapiLookupField calls (one for customer's email, and another for contact.email and contact.entityid) to obtain the customer and contact information:

Example:

function joinFieldsInAnArray()
{
      var customer_id = 1;// customer's internal id

      var cust_fields = ['email','contact.email','contact.entityid'] ;

      var contactfname = nlapiLookupField('customer',customer_id,cust_fields);

      var custEmail= contactfname.email;
      var conEmail= contactfname['contact.email'];
      var conEnt = contactfname['contact.entityid'];

      nlapiLogExecution('DEBUG','customer.email',custEmail);
      nlapiLogExecution('DEBUG','contact.email',conEmail);
      nlapiLogExecution('DEBUG','contact.entityid',conEnt);


}
 


DISCLAIMER: The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations. NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto. NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.

No comments:

Post a Comment