Hi all. I have the Advanced PDF/HTML template that...
# suitescript
d
Hi all. I have the Advanced PDF/HTML template that starts with the following:
Copy code
<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd"><pdfset>
<#if statements?has_content><#list statements as statement>
<pdf>
Inside my Suitlet script I use render module to use that template:
Copy code
const renderer = render.create();
renderer.setTemplateByScriptId({scriptId: 'CUSTTMPL_928018_117'});
context.response.writePage({pageObject: renderer.renderAsPdf()});
What is the right way to specify this "statements" variable in Suitelet script?
d
@Dmitry Masanov no need to create a variable, just add the record, since it is standard variable defined by netsuite. please refer the below code
var myContent = renderer.addRecord({ templateName: 'record', record: record.load({ type: record.Type.CUSTOMER, id: 1234 }); });
d
Thanks @D17339! So what is templateName? Can it be any value?
d
let it be a record, because if you see the standard templates (CUSTTMPL_928018_117) it will be referred to as a record, if your template is a custom template you can specify your templateName.
d
Thank you! I will try that.
@D17339 I tried adding the customer record, but seems it didn't fill statements variable.
d
Then i think u should create your own Custom Data / search results to fill it up, renderer.addCustomData or renderer.addSearch api
Create your own xml content as well similar to CUSTTMPL_928018_117
d
Thanks @D17339! I finally managed to make it work!
👍 1