Hello NetSuite Community,
I am encountering an issue where I’ve added a link to each invoice using a Suitelet URL within the Statement PDF. When I click on the invoice link, the corresponding invoice PDF is expected to be generated and downloaded.
However, the invoice PDF is not being generated when the link is clicked from the saved/locally stored statement PDF.
Steps Taken:
- I have a statement PDF with a list of invoices, and each invoice has a corresponding link that is generated dynamically through the statement template.
- The Suitelet URL is used within the statement template to link to the invoice PDFs generated using Suitelet.
- When the statement is viewed online, clicking the invoice link works as expected, and the invoice PDF is generated.
- However, when the statement PDF is saved locally and then opened, clicking the invoice link does not trigger the generation of the invoice PDF.
Attached the code used:
Statement PDF Template
<td colspan="12">
<#if line.description?contains("Invoice")>
<#assign invoiceText = line.description />
<#assign invoiceId = invoiceText?replace("Invoice #", "")?trim />
<#assign suiteletUrl = "https://<your_accountid>.extforms.netsuite.com/app/site/hosting/scriptlet.nl?script=222&deploy=1&compid=TD3054558&ns-at=AAEJ7tMQdP93Irqevwi2P3CS74Xan1Es&invoiceId=" + invoiceId />
<a href="${suiteletUrl}" target="_blank" style="color: blue;">${invoiceText}</a>
<#else>
${line.description}
</#if>
</td>
Suitelet Code
// Generate PDF using Internal ID
let pdfFile = render.transaction({
entityId: invoiceInternalId,
printMode: render.PrintMode.PDF
});
if (pdfFile) {
response.addHeader({ name: 'Content-Type', value: 'application/pdf' });
response.writeFile({ file: pdfFile });
}
Expected Behavior:
- When clicking on an invoice link in a downloaded statement PDF, the corresponding invoice PDF should be generated by the Suitelet and either displayed inline or downloaded.
Could you please help me understand why the invoice PDF is not being generated or displayed when the statement PDF is saved and the invoice link is clicked?