//Library //1iePjnglUzelAuJJb-QykRcUUWYBSKiNGUWVljnNe03G9zWzSUGIRWLXa function runPDF() { //App Script of Google Form //var spreadSheet = SpreadsheetApp.openById("xxx"); //Google Sheet ID //var dataSheet = spreadSheet.getSheetByName("xxx"); //Sheet Name //App Script of Google Sheet //var spreadSheet = SpreadsheetApp.getActiveSpreadsheet(); //var dataSheet = spreadSheet.getActiveSheet(); //var lastRow = dataSheet.getLastRow(); let sheetId = "xxx"; //Google Sheet ID let sheetName = "xxx"; //Sheet Name let tmpFileId = "xxx"; //Google Slide ID let pdfFolder = DriveApp.getFoldersByName("pdf_folder").next(); //PDF Folder let templateFile = DriveApp.getFileById(tmpFileId); let data = PdfService.initData(sheetId,sheetName); //extend with ,3 -> run row 3 | ,2,5 -> run row 2 to row 5 | blank -> run last row only //let data = PdfService.initData(sheetId,sheetName,2,lastRow); //run row 2 to last row let option = { pdfFolder: pdfFolder, templateFile: templateFile, data: data, image_column: ["รูปถ่าย"], fileName: ["ชื่อ-สกุล","วันที่เริ่มต้น","วันที่สิ้นสุด"] } PdfService.createPDFFromSlide(option); }
function mail_line_calendar() { //App Script of Google Form var spreadSheet = SpreadsheetApp.openById("xxx"); //Google Sheet ID var dataSheet = spreadSheet.getSheetByName("xxx"); //Sheet Name //App Script of Google Sheet //var spreadSheet = SpreadsheetApp.getActiveSpreadsheet(); //var dataSheet = spreadSheet.getActiveSheet();
var lastRow = dataSheet.getLastRow();
var name = dataSheet.getRange(lastRow,2).getValue(); var start_date = dataSheet.getRange(lastRow,3).getValue(); var stop_date = dataSheet.getRange(lastRow,4).getValue(); var mail = dataSheet.getRange(lastRow,5).getValue(); var photo = dataSheet.getRange(lastRow,6).getValue(); var form_file = dataSheet.getRange(lastRow,7).getValue();
var calendar = CalendarApp.getCalendarById("xxx"); //Google Calendar ID var titles = (name); var descriptions = mail_text; calendar.createEvent(titles,start_date,stop_date,{description:descriptions}); }
leave_form
ชื่อ-สกุล | วันที่เริ่มต้น | วันที่สิ้นสุด | อีเมล | รูปถ่าย
//Library
//1iePjnglUzelAuJJb-QykRcUUWYBSKiNGUWVljnNe03G9zWzSUGIRWLXa
function runPDF()
{
//App Script of Google Form
//var spreadSheet = SpreadsheetApp.openById("xxx"); //Google Sheet ID
//var dataSheet = spreadSheet.getSheetByName("xxx"); //Sheet Name
//App Script of Google Sheet
//var spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
//var dataSheet = spreadSheet.getActiveSheet();
//var lastRow = dataSheet.getLastRow();
let sheetId = "xxx"; //Google Sheet ID
let sheetName = "xxx"; //Sheet Name
let tmpFileId = "xxx"; //Google Slide ID
let pdfFolder = DriveApp.getFoldersByName("pdf_folder").next(); //PDF Folder
let templateFile = DriveApp.getFileById(tmpFileId);
let data = PdfService.initData(sheetId,sheetName); //extend with ,3 -> run row 3 | ,2,5 -> run row 2 to row 5 | blank -> run last row only
//let data = PdfService.initData(sheetId,sheetName,2,lastRow); //run row 2 to last row
let option = {
pdfFolder: pdfFolder,
templateFile: templateFile,
data: data,
image_column: ["รูปถ่าย"],
fileName: ["ชื่อ-สกุล","วันที่เริ่มต้น","วันที่สิ้นสุด"]
}
PdfService.createPDFFromSlide(option);
}
function mail_line_calendar()
{
//App Script of Google Form
var spreadSheet = SpreadsheetApp.openById("xxx"); //Google Sheet ID
var dataSheet = spreadSheet.getSheetByName("xxx"); //Sheet Name
//App Script of Google Sheet
//var spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
//var dataSheet = spreadSheet.getActiveSheet();
var lastRow = dataSheet.getLastRow();
var name = dataSheet.getRange(lastRow,2).getValue();
var start_date = dataSheet.getRange(lastRow,3).getValue();
var stop_date = dataSheet.getRange(lastRow,4).getValue();
var mail = dataSheet.getRange(lastRow,5).getValue();
var photo = dataSheet.getRange(lastRow,6).getValue();
var form_file = dataSheet.getRange(lastRow,7).getValue();
//Logger.log(start_date);
//Logger.log(stop_date);
var mail_subject = name+" | "+start_date+" - "+stop_date;
var skeleton = "ชื่อ-สกุล : %s
"+
"วันที่เริ่มต้น : %s
"+
"วันที่สิ้นสุด : %s
"+
"รูปถ่าย : %s
"+
"แบบฟอร์ม : %s
";
var mail_text = Utilities.formatString(skeleton,name,start_date,stop_date,photo,form_file);
MailApp.sendEmail(mail,mail_subject,mail_text);
//Library NotifyApp
//1vXbZfRP-7AqwqV7k0fGAnVjCe34pYyI2WdZBJw1Y8U0_DuEbo5fN32P9
let token = ""; //LINE Token
NotifyApp.sendNotify(token,mail_text);
var calendar = CalendarApp.getCalendarById("xxx"); //Google Calendar ID
var titles = (name);
var descriptions = mail_text;
calendar.createEvent(titles,start_date,stop_date,{description:descriptions});
}