I have a Form that when submitted will trigger a function to write the values of that submittal to the proper sheet in a Spreadsheet. I then wish to email that adjusted sheet to someone.
I searched google api for help and could not resolve or reverse engineer the proper code
function sendpdf(){ // Function trigger is on form submit
var ss = SpreadsheetApp.getActiveSheet();
var sourceSheet = ss.getSheetName();
var workingRow = ss.getLastRow();
var dataRange = ss.getRange(workingRow, 1, 1, 4);
var data = dataRange.getValues();
var row = data[0]; // entire row
var col1 = row[0]; // first column timestamp A
var col2 = row[1]; // Client B
var col3 = row[2]; // Item C
var sass = SpreadsheetApp.getActiveSpreadsheet();
var targetSheet = sass.getSheetByName(col2);
targetSheet.insertRowBefore(4);
targetSheet.getRange("A4").setValue(col1);
targetSheet.getRange("B4").setValue(col2);
targetSheet.getRange("C4").setValue(col3);
MailApp.sendEmail(to:"reciever@email.com",subject:"See Attached PDF regarding" + col2,body:col2+" submitted a new request"
// , attach:targetSheet.pdf
// need the code to turn the targetSheet into a PDF and then email the PDF
)
}
The Spreadsheet contains 12 sheets and I expect the script to email the proper sheet that was just adjusted to someone any help would be appreciated