Hello Guys , I want to attach sales order in pdf, ...
# suitescript
j
Hello Guys , I want to attach sales order in pdf, like I would do here in UI, How can I do that with script. I am doing like var records = new Object(); records['transaction'] = recordId; var emailMerger = nlapiCreateEmailMerger(templateId); emailMerger.setTransaction(recordId); var mergeResult = emailMerger.merge(); var emailSubject = mergeResult.getSubject(); var emailBody = mergeResult.getBody(); nlapiSendEmail(author,recipient,emailSubject,emailBody,null,null,records,fileObj,false,true); but it doesn't work. Thread in Slack Conversation
w
Where do you get
fileObj
from? I would assume that you have generated a PDF with
fileObj = nlapiPrintRecord('TRANSACTION',recordID,'PDF',null);
j
No , fileobj is different file, that I am attaching to this
does records object do something? I thought it would send a copy of transaction in the mail. but it is not doing anything
w
the record-part of nlapiSendEmail() allows you to attach the outgoing email to that record. It has nothing to do with attaching inside the email.
👍 1
you need to generate the PDF and add it to an array of nlobjFile and then supply it to the attachments-parameter in nlapiSendEmail()
var firstFile = nlapiLoadFile(); <- your other file
var invoicePDF = nlapiPrintRecord('TRANSACTION',recordID,'PDF',null);
var attachments = [invoicePDF, firstFile];
nlapiSendEmail(author,recipient,emailSubject,emailBody,null,null,records,attachments,false,true);
j
ohh, so my understanding was wrong , thanks for this explanation. I will do same.