Can someone help me (a beginner) with this server-side script please. I want emails to send when a custom field changes on the sales order. I put in this User Event (After Submit) script, and it works perfectly in Debugger, but does nothing when I set it to Released in system.netsuite.com. I'm sure it's something simple for one of you experts out there!
Thanks in advance!
function sendMail(type){ var currentRecord = nlapiGetNewRecord(); var status = currentRecord.getFieldValue('custbody_repair_status'); var strItem = nlapiGetLineItemValue('item', 'description', 1) var currentCustomer = nlapiGetFieldValue('entity'); var strCustomer = nlapiGetFieldText('entity'); var customerEmail = nlapiLookupField('entity', currentCustomer, 'email'); var emailMessage9 = 'Dear ' + strCustomer + ',' + '<br /><br />' + 'We have begun diagnostic work on your unit.' + '<br /><br />' + 'We will keep you posted...'; var emailSubject9 = 'Work Begun Notification'; var emailMessage10 = 'Dear ' + strCustomer + ',' + '<br /><br />' + 'We are now resolving the issues on your unit.' + '<br /><br />' + 'You are in good hands...'; var emailSubject10 = 'Repair Notification'; var emailMessage11 = 'Dear ' + strCustomer + ',' + '<br /><br />' + 'We are finished!' + '<br /><br />' + 'Your unit is now ready for pickup.' + '<br /><br />' + 'Please feel free to drop by anytime.'; var emailSubject11 = 'Work Completed Notification'; if ((status == '2') && (customerEmail != '')) { nlapiSendEmail(681, customerEmail, emailSubject9, emailMessage9, null); } else if ((status == '3') && (customerEmail != '')) { nlapiSendEmail(681, customerEmail, emailSubject10, emailMessage10, null); } else if ((status == '4') && (customerEmail != '')) { nlapiSendEmail(681, customerEmail, emailSubject11, emailMessage11, null); } }