Is there anyway to get the template id of a record...
# suitescript
e
Is there anyway to get the template id of a record, dynamically? I have a suitelet that presents a sublist of invoices that might have different advanced pdf forms. I want the user to be able to select multiple invoices, so I can combine the PDFs into 1 single file for printing/emailing. I have everything working except figuring out how to pass a dynamic template id. I cannot pass a hardcoded id because of the different custom forms and advanced pdf forms of the invoices in the sublist.
b
use render.transaction instead
e
ok so I have changed to 2.0 but I am still having trouble figuring out if this is possible. The user selects a handful of invoices in a Suitelet sublist and selects to Print them. I want there to be 1 printout with the invoices on separate pages. Each invoice could be using a different advanced pdf template
Copy code
var xmlStr = "<?xml version=\"1.0\"?>\n" +
    "<!DOCTYPE pdf PUBLIC \"-//big.faceless.org//report\" \"report-1.1.dtd\">\n" +
    "<pdf>\n<body font-size=\"18\">";

var rs =  search.create({
    type: record.Type.INVOICE,
    filters: [['internalid', search.Operator.ANYOF, intIds], 'AND', ['mainline', <http://search.Operator.IS|search.Operator.IS>, 'T']],
    columns: ['internalid'],
}).run();
var results = rs.getRange(0, 1000);

for (var i = 0; i < results.length; i++) {
    var renderer = render.create();
    renderer.addRecord({
        templateName: 'record',
        record: record.load({
            type: 'invoice',
            id: results[i].id,
        })
    });
    renderer.templateContent = 'INV: ${record.tranid} ${record.id}<p style="page-break-after: always;"></p>';
    xmlStr += renderer.renderAsString().replace(/&(?!(#\\d+|\\w+);)/g, "&$1");
}

xmlStr += '</body>\n</pdf>';

var pdfFile = render.xmlToPdf({
    xmlString: xmlStr
});

context.response.writeFile({
    file: pdfFile
});
b
use a pdfset to combine your pdfs