Hi, is there a way to print a pdf for a transactio...
# beginners
b
Hi, is there a way to print a pdf for a transaction record using a custom button and advanced/basic pdf template?
d
Yes there is, although I wouldn't consider it too #C5Y8YA27Q-friendly Basically to get a print button (in view mode), you first have a User Event script create a custom button; that button points to a Client script that itself launches a Suitelet that renders the PDF (typically from a PDF template) Have a look at this person's scripts (although I haven't checked them). They're hard-coding a XML to render, rather than using N/render to set a PDF template and add a record: https://netsuiteprofessionals.slack.com/archives/C29HQS63G/p1625564469282600
šŸ‘ 1
šŸŽ‰ 1
It's worth noting that there are bundles out there that can do this kind of thing for you
b
Thanks a lot that method on the N/render is the one I’m was looking for
Hi David, thanks again for your help. I tried implementing this but ran into error
MISSING_PDF_PARAMETERS
. Below is the code block. Am I missing anything here?
Copy code
const renderer = render.create();
renderer.addRecord(
        "record",
        record.load({
          type: recType,
          id: recId,
        })
      );
renderer.setTemplateByScriptId("custtmpl _pi_pdf_template");
const pdfFile = renderer.renderAsPdf();
Script fails on that last line with that error.
d
Close, but wrong param signature for TemplateRenderer.addRecord(). need to pass it an object with
templateName
and
record
keys. i.e. šŸ‘‡