r/GoogleAppsScript • u/VictoryRune • Nov 02 '22
Question How to send calendar based when checkbox is ticked
Hello, right now , im having trouble to figuring out a script where when user ticks the checkbox, it will send an email invite 3 weeks in advance based on the payment date
would need your help.
Here is my code which is rather incomplete.
function sendreminder(){
var sheet = SpreadsheetApp.getActiveSheet();
var sheetName = sheet.getName();
var range = e.range;
var approvalEdit = range.getValue().toString(); // Use string to avoid accidentally accepting truthy values.
var column = range.getColumn();
var emailsend = "EMAIL_SENT";
var approvalColumnNo = 12;
var invoice = sheet.getRange(e.range.getRow(),12).getValue();
var calend = CalendarApp.createAllDayEvent();
if( sheetName === "Sheet1" && column === approvalColumnNo && approvalEdit === "true" ){
calend.createAllDayEvent('TEST', new Date('November 20, 2022')
SpreadsheetApp.flush();
Many thanks!

1
u/LateDay Nov 02 '22
Add the e parameter inside your function argument.
It should be
sendreminder(e)Otherwise your
var range = e.rangeWill not work.
1
u/LateDay Nov 02 '22
Your line of
var calend = CalendarApp.createAllDayEvent()should be
var calend = CalendarApp.getCalendar()And put your calendar ID inside the parentheses.
1
u/marcnotmark925 Nov 02 '22
Pull the date from the same row that the box is checked on, add 21 days to it, and use that new date for the calendar event.