/**
*@NApiVersion 2.1
*@NScriptType Suitelet
*/
define(['N/record','N/render'],
(record, render) => {
onRequest = (context) => {
// templates to render - Change these IDs to the IDs of the templates you want to render
const templates = [102, 107, 108];
const renderer = render.create();
// attach the sales order record
const salesOrderRecord = record.load({
type: record.Type.SALES_ORDER,
id: 22326
});
renderer.addRecord('record', salesOrderRecord);
// render each template and put in array
let salesOrderPDFArray = [];
for (let i = 0; i < templates.length; i++) {
renderer.setTemplateById(templates[i]);
var soasString = renderer.renderAsString();
// remove the first line
soasString = soasString.replace('<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">', '');
salesOrderPDFArray.push(soasString);
}
let finalXML = '<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">';
finalXML += '<pdfset>' + salesOrderPDFArray.join('') + '</pdfset>';
// render final xml
context.response.renderPdf(finalXML);
}
return {onRequest};
});
Jaime Requena is a seasoned NetSuite Consultant and Solutions Architect, known for delivering WHITE GLOVE service to businesses. With 15+ years of experience and 3x certifications in ERP, Developer, and Admin, Jaime specializes in highly customized NetSuite accounts, transforming operations for 200+ satisfied customers all across the globe.
We aim to bring unmatched expertise and professionalism to your NetSuite initiatives. Let’s talk about how our NetSuite consultancy can make a difference!
It’s Been 4+ Years Now And We Have Worked With Hundreds Of Clients, Building Our Way To The Top, One Happy Client After Another! Their Voices Of Satisfaction Serve As A Testament To Our Success –