How would I generate a url in suitescript to show ...
# suitescript
n
How would I generate a url in suitescript to show the printed version of an invoice
k
I think you need to save it in the file cabinet before being able to show it
n
@Kyriakos Zisopoulos no way to render it or anything like that as a pdf?
k
I dont know of a way to be honest, those adv pdf templates they are build on request in order to print show the pdf. In suitescript you can render but there is no url. Maybe someone else knows a way
d
You can create a Suitelet that just loads the template, adds the record required and prints it. And use the link of this Suitelet
n
@Dmitry Masanov using the render module i am guessing in that suitelet?
d
Copy code
const renderer = render.create();
renderer.setTemplateByScriptId({
    scriptId: <templateID>,
});

renderer.addRecord({
    templateName: "record",
    record: record.load({
        type: record.Type.INVOICE,
        id: <invoiceID>
    }),
});
context.response.addHeader({
        name: "Content-Type:",
        value: "application/pdf",
});
context.response.addHeader({
        name: "Content-Disposition",
        value: `inline; filename="somename.pdf"`,
});
context.response.writePage({
        pageObject: renderer.renderAsPdf(),
});
Something like that
n
Ahh cool, I'll give it a whirl. Thanks!