Following the example in the help I have the following code:
// Send the notification email to the rep try { // get the rep/partner name var salesRepId = record.getFieldValue(ENTITY_FIELDS.REP); var repRecordId = REC_IDS.EMPLOYEE; if(IsNullOrEmpty(salesRepId)) { salesRepId = record.getFieldValue(ENTITY_FIELDS.PARTNER); repRecordId = 'partner'; } if(IsNullOrEmpty(salesRepId) == false) { // lookup the rep fields var repName = nlapiLookupField(repRecordId, salesRepId, 'firstname'); var fields = new Array(); fields['NLEFFECTIVEREP'] = repName; var notificationEmail = nlapiMergeRecord('30', REC_IDS.CUSTOMER, record.getId(), null, null, fields) var records = new Array(); records[REC_IDS.CUSTOMER] = record.getId(); nlapiSendEmail('-5', salesRepId, 'Patient File Received', notificationEmail.getValue(), null, ['xxx@xxx.com', 'xxx@xxxx.com'], records); log('notification email sent to rep: ' + salesRepId + ' for patient: ' + record.getId()); } } catch(errrrr) { logException(errrrr); } The emails are being sent, at least that part is working but they are not being attached to the customer record.BTW, REC_IDS.CUSTOMER = 'customer'I've tried the following: var records = new Object(); records[REC_IDS.CUSTOMER] = record.getId();
and var records = new Array(); records[REC_IDS.CUSTOMER] = new String(record.getId());