I want to send data from a row in a spreadsheet to get filled into a google doc (at specific places) whenever a certain trigger is activated in the spreadsheet. Also, I want to attach a certain table to the doc (suppose we have 4 different tables). Like before hitting the trigger, I want to choose one of the tables to go into the doc. And then, when the doc is created, email it in a pdf form to the creator and the email address entered in the row for which the trigger was sent.
function myfunk() {
const ss = SpreadsheetApp.getActive();
const doc = DocumentApp.create("Sample");
const sh = ss.getSheetByName("Sheet1");
const vs = sh.getRange("A2:F10").getValues();
doc.getBody().appendTable(vs);
doc.getBlob().getAs('application/pdf');
doc.saveAndClose();
GmailApp.sendEmail("bob@gmail.com,"Data your looking for","Hi Bob: Here it is",{attachments:[doc]});
}