Hi,
I have a script that is automatically sending an email to a custom record in our system.
The (simplified) script is shown below
function afterSubmitPartnerApplication(type){
if (type != 'delete') {
var id = nlapiGetRecordId();
var type = nlapiGetRecordType();
var notification = nlapiGetFieldValue('custrecord_notificationsent');
if (notification == 'F') {
var status = nlapiGetFieldValue('custrecord_applicationstatus');
var name = nlapiGetFieldValue('custrecord_firstname') + ' ' + nlapiGetFieldValue('custrecord_lastname');
var hruser = '15386';
var emailRecords = new Object();
emailRecords['recordtype'] = 'customrecord_partnerapplication';
emailRecords['record'] = id;
var emailFields = new Object();
var attachments = new Array();
emailFields['NLFULLNAME'] = name;
var user = hruser;
var email = nlapiGetFieldValue('custrecord_emailaddress');
if (status == '13') {
var template = '105';
attachments[0]= nlapiLoadFile('21947');
attachments[1]= nlapiLoadFile('21948');
var subject = 'Your Application With the Clean Space';
}
var body = nlapiMergeRecord(template, type, id, null, null, emailFields).getValue();
nlapiSendEmail(hruser, email, subject, body, null, null, emailRecords, attachments);
nlapiSubmitField(type, id, 'custrecord_notificationsent', 'T');
}
}
}
However, when the script runs the email that gets sent out has two copies of each of the attachments (i.e. four files - not two as expected).I'm guessing my array is built incorrectly but it looks right to me.Can anyone spot what's going on here?Thanks!Charlie