//Info: HL-174
We encountered a scenario in which we had to save the errors generated to the file cabinet as a CSV file and then attach this file to the specific email id provided.
if (csvFileData) //if csvFileData contains any values or errors
{
let fileObj = file.create({
name: 'ERROR-' + '-' + Math.floor(Date.now() / 1000) + '.csv',
fileType: file.Type.CSV,
folder: 1078,
contents: csvFileData
});
fileID = fileObj.save();
//error sending via mail
var fileData = file.load({
id: fileID
});
email.send({
author: -5,
recipients: 'xyz@domain.com',
subject: 'Import Error File',
body: 'File attached',
attachments: [fileData]
});
}