when a booking is occurred, a voucher get generated.
On the voucher record the field contact name field should be linked to the contact record then.
Create a new field under the custom voucher record as list type then select the contact as its value
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 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',
voucher.setFieldValue('custrecord_treating_dentist', contactid);
voucher.setFieldValue('custrecord_bookedby', formValues.bookedBy); //1.4.2 Set the Booked By Field - RD // 1.4.3 DW
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
}