Jan Krejcik
08/28/2024, 8:18 PMconst pdfFile = renderer.renderAsPdf();
var fileObj = file.create({
name: `${custName} - FSA.pdf`,
fileType: file.Type.PDF,
contents: pdfFile.getContents(),
folder: 47453 // Replace with your target folder ID
});
var fileId = fileObj.save();
// Attach the file to the customer record
try {
var attachId = record.attach({
record: {
type: 'file',
id: fileId
},
to: {
type: 'customer',
id: curRecID
}
});
log.debug('File attached to customer', `Attach ID: ${attachId}, File ID: ${fileId}, Customer ID: ${curRecID}`);
} catch (attachError) {
log.error({
title: 'Error Attaching File',
details: attachError.message,
});
}
Debug result: Attach ID: null, File ID: 81907, Customer ID: 229ericl
08/28/2024, 8:41 PMericl
08/28/2024, 8:41 PMJan Krejcik
08/29/2024, 8:41 AMericl
08/29/2024, 12:33 PMJan Krejcik
08/29/2024, 1:08 PMericl
08/29/2024, 1:26 PMericl
08/29/2024, 1:28 PM