This article is relevant if you need to use NetSuite to print transactions but the role does not provide sufficient permissions.
Background
We recently created a customer invoice approval process for a client who needed complex criteria based assignments to different actors in their organization. Those actors use the employee NetSuite license which disallows access to the invoice record. We created a SuiteLet so we could run under a higher permission level so we could update records as needed.
One requirement was for the approver to be able to see the actual invoice PDF during their review process. Calling out to NetSuite’s native print routine requires proper permissions. So we ended up creating a “Proxy” print routine that would allow printing any transaction. I would like to thank Carl Z., Technical Consultant, for his contribution to this solution.
SuiteLet SuiteScript 2.0 to Print NetSuite Transactions
The SuiteLet will act as an intermediary to allow an administrator the ability to grant higher access permissions so that the built-in print routines will work. The following SuiteLet code is the bare minimum needed to pass a transaction ID parameter and produce the output.
define([ 'N/render' ], function(render) { function onRequest_PrintProxy(context) { if (context.request.method === 'GET') { var oPDF = render.transaction({ entityId : parseInt(context.request.parameters.tranid) }) context.response.writeFile({ file : oPDF, isInline : true }); } } return { onRequest : onRequest_PrintProxy }; } );
Here is an example of the URL to call the SuiteLet:
https://tstdrv1030358.app.netsuite.com/app/site/hosting/scriptlet.nl?script=752&deploy=1&tranid=38359
Note the &tranid parameter at the end of the URL.
The actual code we created was much more robust as we included error handling and flexibility to work with other record types and Advanced PDF templates. We supply the SuiteLet as one of the many utilities we offer to our clients without license charges.
Supercharge Advanced PDF Creation
While closely related to Advanced PDF generation, regular readers will know that since 2015, we have a tool called the Content Renderer Engine (CRE) that allows you to join multiple saved searches together to extend the HTML/PDF (and any string) output (including Excel files). See my article, Supercharge NetSuite Advanced PDF/HTML Templates.
Leverage Our Team’s Previous Client Work
Since 2008, our NetSuite Systems Integration Practice has seen so many NetSuite situations. We continue to catalog and inventory our SuiteScript algorithms to act as accelerators to help our clients realize the promise of the NetSuite platform.
If you found this article meaningful, feel free to subscribe to get notifications of new posts. If you would like to solve your NetSuite printing challenge, let’s have a conversation.