I'm trying to get a spreadsheet to add a calendar event on the date I need to reorder medications (calculated in the sheet based on a stock check) . Before I get to looping through them all, I'm just trying to get one entry to work and build up from there. The code I've got so far is:
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendarId = spreadsheet.getRange("A20").getValue();
var eventCal = CalendarApp.getCalendarById(calendarId);
var medName = spreadsheet.getRange("A2").getValue();
var startTime = spreadsheet.getRange("I2").getValue();
var endTime = spreadsheet.getRange("I2").getValue();
function addMedReminder(){
eventCal.createEvent(medName, new Date(startTime), new Date(endTime));
Logger.log(medName);
Logger.log(startTime);
Logger.log(endTime);
}
And gives me a log that looks like this:
Execution log
12:25:29 Notice Execution started
12:25:29 Info Alimemazine
12:25:29 Info Tue Oct 06 00:00:00 GMT+01:00 2026
12:25:29 Info Tue Oct 06 00:00:00 GMT+01:00 2026
12:25:32 Notice Execution completed
So far so good but what I want to be able to do is set the time of the event to 10:00 and end at 10:30 so I can add in a popup reminder.
I've tried concatenate the date cell and time in the spreadsheet and putting it in manually into the new Date, I just can't get the syntax to work.