Hey all, I am trying to print an Invoice Group fro...
# suitescript
m
Hey all, I am trying to print an Invoice Group from a Suitelet, I tried with the following code:
Copy code
var renderer = nRender.create();

        renderer.addRecord('record', nRecord.load({
            type: 'invoicegroup',
            id: 18
        }));

        renderer.setTemplateByScriptId("xxxxxxxxxx");
        context.response.writeFile(renderer.renderAsPdf());
but i am getting an error saying Missing parameters required to generate PDF, anybody has any ideas?
b
whats the template look like
m
it's just the standard group invoice pdf customized (with nothing added)
Invoice Group(Summary View) PDF/HTML Template
maybe i need to load invoicegroupsummary or something instead of invoicegroup?
b
the standard templates also require you to add lists
take a look at the template code for the data used by the template
m
groupedinvoices_summary
i see this there
maybe if i try to delete it and see if it will run?
b
depends on how important you think that data is for printing
you can get rid of it if you just want to print something
m
right now i want to know what's causing the error, but i will need that data later
i have removed it saved it and ran the suitelet again and same error
i also see this: ${companyInformation.companyName}
is this available by default on the pdf, or do i need to add it?
b
you only added a record key to your data
if you just want it to print, then you can only use expressions involving record
t
as far as I know companyInformation is available by default when using render api. Its the ${subsidiary.<fieldid>} schema that is not available unlike when using advanced pdf function. Can you try renderAsString to see if there will be no error? If there is no error then then you can use that string in calling render.xmlToPdf. If you get the same error with xmlToPDf, then there is probably an issue with your template
m
hey guys, just thought i passed by to let you know that i was able to fix it. in the end, I had to create a file instead of just using an advanced pdf
Copy code
let file = nFile.load(59451).getContents();
        let renderer = nRender.create();

        renderer.templateContent = file;
        
        renderer.addRecord({
            templateName: 'record',
            record: nRecord.load({
                type: 'invoicegroup',
                id: 18 
            })
        })

        context.response.renderPdf(renderer.renderAsString());
this is how i did it, thank you for the responses!
i literally tried to leave the advanced pdf blank and was not able to print it
so i had to go another way around