The N/render module generates PDF documents, email HTML bodies, and other rendered outputs from NetSuite’s Advanced PDF/HTML templates. It is the backbone of automated invoice printing, picking slips, packing lists, and custom reports.
Render a Transaction as PDF
define(["N/render", "N/email", "N/log"], (render, email, log) => {
const pdfFile = render.transaction({
entityId: 12345, // Transaction internal ID
printMode: render.PrintMode.PDF
});
log.debug("PDF created", pdfFile.name);
// Attach to an email
email.send({
author: 1,
recipients: ["customer@example.com"],
subject: "Your Invoice",
body: "Please find your invoice attached.",
attachments: [pdfFile]
});
return {};
});
Render a Custom Template
const renderer = render.create();
renderer.setTemplateByScriptId({ scriptId: "custtmpl_my_template" });
renderer.addRecord({ templateName: "record", record: myRecord });
const pdfFile = renderer.renderAsPdf();
Key Methods
| Method | Description |
|---|---|
render.transaction(options) | Render a transaction record to PDF |
render.statement(options) | Render a customer statement |
render.create() | Create a custom renderer object |
renderer.renderAsPdf() | Output the renderer result as a PDF file object |
renderer.renderAsString() | Output as an HTML string |