When Google Form is submitted, it finds the items to replace in the Google Doc template, then emails to me. I am having trouble getting the Form checkbox Response as bullet points in the Doc. It currently will list all options that were checked but they are separated by commas, not bullet points.
Any help on this would be really appreciated!
function onFormSubmit(e) {
//open the template document by ID
//you can find the ID in the link of the document
var templateDoc = DriveApp.getFileById('1Dwbjh1Jqerg_WKvqdERyCfnDnWY2yjNArGY_f38ioAs');
//create a copy of the template, we don't wanna mess up the template doc
var newTempFile = templateDoc.makeCopy();
//open the new template document for editing
var openDoc = DocumentApp.openById(newTempFile.getId());
var body = openDoc.getBody();
//get the responses triggered by On Form Submit
var items = e.response.getItemResponses();
//find the text in the template doc and replace it with the Form response
//items[0].getResponse() is the first response in the Form
//and it is the "Name"
body.replaceText('{Position}', items[0].getResponse());
//items[1].getResponse() is the second and it is the date
body.replaceText('{Location}', items[1].getResponse());
//You can add as much as you have and change them in the Template Doc like this
body.replaceText('{Days/Hours}', items[2].getResponse());
body.replaceText('{Qualifications}', items[3].getResponse());
body.replaceText('{Duties}', items[4].getResponse());
//and so on...
//Save and Close the open document
openDoc.saveAndClose();
var theBlob = newTempFile.getBlob().getAs('application/pdf');
//The name of the file is going to be the first and second question from the form
//change to your preference
var nameFile = items[0].getResponse() + '-' + items[1].getResponse() + '.pdf';
//send an email with the PDF
//If you don't want to send the PDF in the mail just delete everything
//from here -------
var email = 'youremail@email.com';
var subject = 'Your new document';
var body = 'Hello, <br/>Check this PDF file.';
GmailApp.sendEmail(email, subject, body, {
htmlBody: body,
attachments: [{
fileName: nameFile,
content: theBlob.getBytes(),
mimeType: "application/pdf"
}]
});
//to here ------
// save the PDF file in your Drive
var savePDF = DriveApp.createFile (theBlob);
//if you want to save the file in a specific folder use this code
//get the ID from the folder link
//var folder = DriveApp.getFolderById('14nUc----------0lUb');
//var savePDF = folder.createFile (theBlob);
savePDF.setName(nameFile);
//delete the temp file
DriveApp.getFileById(newTempFile.getId()).setTrashed(true);
}

