Eextension for set value in netsuite records

bookVoucher: function (voucherId, archType, formValues, validDate, expressVoucherPair, voucherPairId, validDispatchDate, internalReturnDate) {
  var voucher=null;

  var voucherInfo= {
    updatedVoucherId: 0, updatedVoucherName: ''
  }

  ; //1.2.0

  try {
    if ( !voucherPairId) //1.3.0

      {
      voucherPairId='';
    }

    var contactSearch=nlapiSearchRecord("contact", null,
      [ ["entityid", "is", formValues.treatingDentist]],
      [ new nlobjSearchColumn("entityid").setSort(false),
      new nlobjSearchColumn("email"),
      new nlobjSearchColumn("internalid")]);
    var contactname=contactSearch[0].getValue('entityid');
    var contactid=contactSearch[0].getValue('internalid');
    voucher=nlapiLoadRecord('customrecord_voucher', voucherId);
    voucher.setFieldValue('custrecord_cust_vou_status', bookedStatus); //1.3.0
    voucher.setFieldValue('custrecord_patient_first_name', formValues.firstName);
    voucher.setFieldValue('custrecord_patient_last_name', formValues.lastName);
    voucher.setFieldValue('custrecord_cust_special_inst', formValues.specialInstruction);
    voucher.setFieldValue('custrecord_patient_dob', formValues.dateOfBirth);
    voucher.setFieldValue('custrecord_cust_express', formValues.isExpress);
    voucher.setFieldValue('custrecord_arch', archType); //1.1.0, rather than use formValues.archtype, it is a passed in parameter
    voucher.setFieldText('custrecord_impressiontype', formValues.impressionType); //1.6.1
    //voucher.setFieldValue('custrecord_treating_dentist', contactid);
    voucher.setFieldValue('custrecord_treating_dentist', contactname);
    voucher.setFieldValue('custrecord_bookedby', formValues.bookedBy); //1.4.2 Set the Booked By Field - RD // 1.4.3 DW
    voucher.setFieldValue('custrecord_shipping_address_id', formValues.deliveryAddress); //1.1.3
    voucher.setFieldValue('custrecord_shipping_address', formValues.deliveryAddressText); //1.1.1 
    voucher.setFieldValue('custrecord_date_required', validDate); //calculated the required date MJL
    voucher.setFieldValue('custrecord_dispatchdatetoenlighten', validDispatchDate); // 1.5.0
    voucher.setFieldValue('custrecord_expressvoucherpair', expressVoucherPair); //1.3.0
    voucher.setFieldValue('custrecord_voucherpairid', voucherPairId); //1.3.0
    // 1.4.3 DW
    voucher.setFieldValue('custrecord_custaccountnumber', formValues.accountNum); //1.3.0
    voucher.setFieldValue('custrecord_referredcode', formValues.referafriend); //1.5.1
    voucher.setFieldValue('custrecord_jj_internal_return_date', internalReturnDate); //1.6.5

    if (formValues.methodofSendingScan=='Upload STL Files') {
      voucher.setFieldValue('custrecord_jj_cb_stl_in_dropbox', 'T');
      voucher.setFieldValue('custrecord_jj_en333_sending_scans', 1);
    }

    //1.6.4
    if ((formValues.impressionType=='Digital Scan') && (formValues.methodofSendingScan=='Send STL files through my scanning system')) {
      voucher.setFieldText('custrecord_selectyoursystem', formValues.selectyourSystem);
      voucher.setFieldValue('custrecord_jj_en333_sending_scans', 2);
    }

    voucherInfo.voucherName=voucher.getFieldValue('name'); //1.2.0
    voucherInfo.voucherId=nlapiSubmitRecord(voucher, false, true); //1.2.0
  }

  catch (e) {
    Library.errorHandler('Lab.BookPatient.Model', 'bookVoucher', e);
    this.bookingError=true;
  }

  return voucherInfo; //1.2.0
}

In list record to set the value using the id. setFieldValue to set value to the address of the id. so in netsuite list details can see.

In netsuite using this id the number get displayed.

voucher.setFieldValue('custrecord_treating_dentist_evo4', contactid); //list
voucher.setFieldValue('custrecord_treating_dentist', contactid); //list
voucher.setFieldValue('custrecord_treating_dent_test', contactname); //text

Leave a comment

Your email address will not be published. Required fields are marked *