Im trying to send the same email that is sent from our system if you click on the "email option" from inside an item fulfillment using suitescript 2.0. I have it so I can send an email with a text string body, but I havent been able to pull the advanced pdf template and merge it with the Item Fulfillment. How do I do this. I have been through a lot of iterations, but this is what I currently have as I try to work on it(this gives an error of course):
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define(['N/email','N/render', 'N/record', 'N/file'],
function(email, record, file,render) {
function afterSubmit(context) {
// if (context.type !== context.UserEventType.CREATE)
// return;
function renderTransactionToHtml() {
var myMergeResult = render.mergeEmail({
templateId: 121,
entity: {
type: 'employee',
id: 18040
},
recipient: {
type: 'employee',
id: 18040
},
supportCaseId: 'NULL',
transactionId: 1176527,
customRecord: 'NULL'
});
}
renderTransactionToHtml();
function sendEmailWithAttachement() {
var newId = context.newRecord;
var emailTempId = 121;
var emailbody = 'attachment';
var senderId = 18040;
var recipientEmail = 'email@email.com';
email.send({
author: senderId,
recipients: recipientEmail,
subject: 'Item Fulfillments',
body: emailbody
});
}
sendEmailWithAttachement();
}
return {
afterSubmit: afterSubmit
};
});