Helena
03/18/2023, 5:57 PMlet mySearch = task.create({
taskType: task.TaskType.SEARCH,
});
mySearch.savedSearchId = customStatement;
mySearch.filePath = filePath;
let taskId = mySearch.submit();
let taskStatus = task.checkStatus(taskId);
let fileId = taskStatus.fileId;
let csvFile = file.load({ id: fileId});
let myMergerResult = render.mergeEmail({
templateId: CONSTANTS.Template,
entity: {
type: 'customer',
id: Number(custId)
}
});
email.send({
author: CONSTANTS.author,
recipients: ARContacts,
cc: carbonCopyEmailList,
bcc: [CONSTANTS.scriptAuthor],
subject: myMergerResult.subject,
body: myMergerResult.body,
attachments: [csvFile],
relatedRecords: {
entityId: Number(custId)
}
});
Anthony OConnor
03/18/2023, 6:03 PMAnthony OConnor
03/18/2023, 6:06 PMWatz
03/18/2023, 7:00 PMraghav
03/18/2023, 7:39 PMHelena
03/18/2023, 7:41 PMHelena
03/18/2023, 7:43 PMHelena
03/18/2023, 7:45 PMWatz
03/18/2023, 7:45 PMWatz
03/18/2023, 7:47 PMHelena
03/18/2023, 7:47 PMraghav
03/18/2023, 8:41 PMraghav
03/18/2023, 10:09 PMvar csvHeader = ["Header1","Header2","Header3","Header4"];
csvContent += csvHeader;
search loop {
csvContent += "\r\n";
var csvRow = new Array();
var cell1 = result.getValue();
var cell2 = result.getValue();
var cell3 = result.getValue();
var cell4 = result.getValue();
// please note if any of the cell data has a possible chance of having a comma inside it, then you need to wrap it first in "" or you can replace comma with something else like .replace(/,/g, ';') else it will split the data into 2 different columns
if(cell1.indexOf(",")!=-1) {
cell1 = '"'+cell1+'"';
}
csvRow.push(cell1,cell2,cell3,cell4);
csvContent += csvRow.join();
}
var csvFile = file.create({
name: "xyz.csv",
fileType: file.Type.CSV,
contents: s_csvContent,
encoding: file.Encoding.UTF8
});
email.send({
author: 1234,
recipients: 5678,
subject: emailSubject,
body: emailBody,
attachments: [csvFile],
relatedRecords: null,
cc: null
});
reptar
03/20/2023, 4:07 PMWatz
03/20/2023, 4:09 PMreptar
03/20/2023, 4:12 PMreptar
03/20/2023, 4:13 PMWatz
03/20/2023, 4:13 PMreptar
03/20/2023, 4:14 PMreptar
03/20/2023, 4:21 PMreptar
03/20/2023, 4:22 PMmichoel
03/20/2023, 9:52 PMreptar
03/20/2023, 9:54 PMWatz
03/21/2023, 6:07 AM