I am fairly new to NetSuite scripting and have the following issue.
I am trying to send an email from SuiteScript 1.0. The Script is linked to the AFTER SUBMIT function of Sales Orders.
My code:
function OnAfterSubmit(record) {
var fromId = -5; //Authors' Internal ID
var sbj = 'subject';
var msg = '';
//load File from netSuite Document Repository with ID of 123
var orderid = nlapiGetRecordId();
var search = nlapiSearchRecord('salesorder', orderid);
var fileObj = nlapiLoadRecord(search.getRecordType(), search.getId());
//var detail = getOrderDetail(fileObj);
//Single Attachment - Attach File ID 123
//nlapiSendEmail(fromId, '[email protected]', sbj, msg, null, null, null, fileObj);
//multiple Attachments
//build Array of file objects
var attach = [fileObj];
//pass attach array as attachment parameter
nlapiSendEmail(fromId, '[email protected]', sbj, msg, null, null, null, attach);
}
I am trying to send the record that has been created by the user, via email.
The record parameter doesn't seem to be what I expect. The error I receive says "invalid search". When I used record.id
, the error simply said "id". I also tried record.internalId
.