Paul Vana
09/20/2019, 8:21 PMec
09/20/2019, 8:37 PMrender.transaction({ entityId: transactionId, printMode: render.PrintMode.PDF, formId: templateId });
where transacionId is the internal id of the transaction, and formId is the internal id of the custom formec
09/20/2019, 8:40 PMec
09/20/2019, 8:40 PMoptions.formId number optional The transaction form numbererictgrubaugh
09/20/2019, 9:29 PM<pbr/> tag to insert page breaks wherever you'd likePaul Vana
09/23/2019, 4:23 PMec
09/23/2019, 4:24 PMerictgrubaugh
09/23/2019, 4:48 PM<pbr/> tag directly in the template to break pages there, and you can also use it if you are concatenating multiple transactions together into a single pdfPaul Vana
09/23/2019, 7:24 PMerictgrubaugh
09/23/2019, 7:40 PMvar transactionIds = [100, 123, 45556, 78923];
var pdfBody = transactionIds.map(toPdf)
.map(removeHeader)
.join("<pbr/>");
var pdfContent = pdfHeader + pdfBody + pdfFooter;
The map transformers can of course be combined into a single function, but I wanted to illustrate the stepsPaul Vana
09/23/2019, 7:47 PMPaul Vana
09/23/2019, 7:48 PMerictgrubaugh
09/23/2019, 7:58 PMerictgrubaugh
09/23/2019, 7:59 PMfunction toPDF(id) {
var tmpl = render.create();
tmpl.setTemplateById({id: this});
tmpl.addRecord({
templateName: "record",
record: r.load({type: "customrecord_blah", id: id})
});
var contents = tmpl.renderAsString()
.replace(PDF_HEADER, "")
.replace(PDF_FOOTER, "");
return contents;
}erictgrubaugh
09/23/2019, 8:00 PMrenderAsString() callerictgrubaugh
09/23/2019, 8:00 PMthis is the template IDerictgrubaugh
09/23/2019, 8:00 PM.map(toPDF, templateId)erictgrubaugh
09/23/2019, 8:02 PMerictgrubaugh
09/23/2019, 8:02 PMPaul Vana
09/23/2019, 8:11 PMPaul Vana
09/23/2019, 8:48 PMerictgrubaugh
09/23/2019, 8:51 PMPDF_HEADER module variable, that's what I'd expecterictgrubaugh
09/23/2019, 8:52 PMec
09/23/2019, 8:55 PMPaul Vana
09/23/2019, 9:15 PMPaul Vana
09/23/2019, 9:15 PM{
"type": "error.SuiteScriptError",
"name": "USER_ERROR",
"message": "Error Parsing XML: The reference to entity \"c\" must end with the ';' delimiter.",
"stack": [
"createError(N/error)",
"onRequest(/SuiteScripts/Somnomed-Prod/sm_sl_mass_fulfill_so.js:192)"
],
"cause": {
"type": "internal error",
"code": "USER_ERROR",
"details": "Error Parsing XML: The reference to entity \"c\" must end with the ';' delimiter.",
"userEvent": null,
"stackTrace": [
"createError(N/error)",
"onRequest(/SuiteScripts/Somnomed-Prod/sm_sl_mass_fulfill_so.js:192)"
],
"notifyOff": false
},
"id": "",
"notifyOff": false,
"userFacing": false
}erictgrubaugh
09/23/2019, 9:20 PMerictgrubaugh
09/23/2019, 9:20 PM<pbr/> you could also do something much more complicated/fancy with a <div> or whatever other HTML you can come up witherictgrubaugh
09/23/2019, 9:20 PM<pdfset> does not let you do that