we want to create the option to be able to print Manufacturing operation task record.
it is not supported by the advanced pdf/html vanilla so we need to execute it via suitescript.
we are getting an unexpected error.
any advise on the error or on other best practice related Manufacturing operation task record (WIP) printing
script:
let manufacturingOperationTask = record.load({
type: "manufacturingoperationtask",
id: 121
});
// Get the default Advanced PDF/HTML Template for Manufacturing Operation Tasks
let renderer = render.create();
// renderer.setTemplateById(22); // Custom Bill of Materials PDF/HTML Template
renderer.setTemplateByScriptId({
scriptId: "STDTMPLBOM"
});
// Set data for the template (customize this part based on your actual fields)
renderer.addRecord({record: manufacturingOperationTask});
// Convert HTML to PDF
let pdfFileId = renderer.renderAsPdf();
// Save the PDF file
let savedPDF = file.create({
name: 'Manufacturing_Operation_Task_Report.pdf',
fileType: file.Type.PDF,
contents: pdfFileId
});
let pdf = savedPDF.save();
response.writeFile({file: pdf, isInline: false});
error:
{"type":"error.SuiteScriptError","name":"UNEXPECTED_ERROR","message":"An unexpected SuiteScript error has occurred","id":"5cb7e470-a1fa-42a3-ab9e-0b33eb05c547-2d323032342e30322e3132","stack":["Error\n at Object.renderPdf (/SuiteScripts/render-cookbook.js:22:37)\n at Object.onRequest (/SuiteScripts/RenderPDF.js:15:21)"],"cause":{"type":"internal error","code":"UNEXPECTED_ERROR","details":"An unexpected SuiteScript error has occurred","userEvent":null,"stackTrace":["Error\n at Object.renderPdf (/SuiteScripts/render-cookbook.js:22:37)\n at Object.onRequest (/SuiteScripts/RenderPDF.js:15:21)"],"notifyOff":false},"notifyOff":false,"userFacing":true}