I hope you are welll. I am trying to store dataset results in a csv file. but I am getting error as, SSS_FILE_CONTENT_SIZE_EXCEEDED error. So my plan is to create multiple files. But, I need to check file size, if its 10MB then create second file and store subsequent data in that. My concern is, before saving the file we couldn't get the file size. Thanks in advance!
function summarize(summary) {
let csvContent = [];
let datasetObj = dataset.load({ id: 'custdataset70' });
let headers = datasetObj.columns.map(col => col.label || col.id);
csvContent.push(headers);
summary.output.iterator().each((key, value) => {
csvContent.push(value); // Keep value as string
return true;
});
if (csvContent.length <= 1) { // Only headers, no data
log.debug('No Data', 'No unique dataset records found.');
return;
}
let fileId = saveCSVFile(csvContent.join('\n'));
if (fileId) {
sendEmail(fileId);
}
}
function saveCSVFile(csvContent) {
let today = format.format({ value: new Date(), type: format.Type.DATE });
let csvFile = file.create({
name: 'DatasetResults_' + today + '.csv', // Dynamic filename
fileType: file.Type.CSV,
contents: csvContent,
folder: 5081389
});
return csvFile.save();
}