const TEMPLATE_INTERNAL_ID = 123 //advanced template internal id under customisation > forms > advanced PDF templates
let myFile = render.create();
myFile.setTemplateById(TEMPLATE_INTERNAL_ID);
myFile.addRecord('record', record.load({
    type: 'customrecord_name', //record type
    id: recordId //record id
}));
let pdfObj = myFile.renderAsPdf();
let fileObj = file.create({
    name: 'yourpdf.pdf',
    fileType: file.Type.PDF,
    contents: pdfObj.getContents()
})
fileObj.folder = -4 //your folder id
const fileId = fileObj.save()
Last modified: 13/11/2024

Author

Comments

Write a Reply or Comment

Your email address will not be published.