3

Hi and I I am not a pain, I got help on sending a statement and that worked perfectly, but I need to send invoices with it but I can't find a method for that like I did for the statement. I find references to using a template file, then you have to store the file in the cabinet. I have to attach there to emails, what would you think the best way to do this?

Here is the other link, he gave a very helpful complete answer about sending statements. I should have asked him about invoices at the same time but I didn't think of it, apologies.

SuiteScript 2 can send pdf statements

added additional info Ok I tried this but I am getting an error that doesn't make sense as I am using their templates. "error.SuiteScriptError","name":"USER_ERROR","message":"Error Parsing XML: The reference to entity \"c\" must end with the ';' delimiter.",

require(['N/render', 'N/file', 'N/record'],
function(render, file, record) {
function renderRecordToPdfWithTemplate() {

var renderer = render.create();
renderer.setTemplateByScriptId("STDTMPLCUSTINVC");
var xml = renderer.renderAsString();

renderer.addRecord(record.Type.INVOICE, record.create({
type: record.Type.INVOICE,
id:415619
}));
var invoicePdf = renderer.renderAsPdf();

var foo = this;

}
renderRecordToPdfWithTemplate();
});

thanks for any help with this

Community
  • 1
  • 1
jk121960
  • 843
  • 14
  • 45

1 Answers1

3

Ok I found it thanks if anyone was looking for this for me. It is pretty straightforward, but like NetSuite always is, you have to find it. :) the entityid is the invoice internalid the rest is easy, then just pass the file object to the email.

require( [ 'N/render', 'N/file', 'N/record' ],
function( render, file, record ) {
function renderRecordToPdfWithTemplate() {


var transactionFile = render.transaction({
    entityId: 415619,
    printMode: render.PrintMode.PDF
});

var foo = this;

}

renderRecordToPdfWithTemplate();
} );

thanks again

jk121960
  • 843
  • 14
  • 45
  • Just curious. You were able to use that script with require only, instead of define? – w3bguy May 01 '17 at 18:27
  • 1
    When in the debugger that is what you have to do, it doesn't see define. Just like NetSuite, LOL, always inconsistent. – jk121960 May 01 '17 at 20:00
  • Okay, I thought you were actually running it like that... :) I know you can; but, I think you have to have a define that still calls it (when not using the debugger). Hey, at least NetSuite keeps it interesting... lol. Code works one day, then returns random errors the next... :D – w3bguy May 02 '17 at 13:48