javascript - Google Apps Script: Email Reminder Have Time Pulled from Column Values -
i'm trying create google sheets setup script create calendar events , set reminder times events.
i have working 1 exception: want able have column "reminder time" each cell in column can have different reminder time correspond given calendar entry (so example, type a, calendar event created reminder 3 days in advance, type b, calendar event created 6 days in advance, in "reminder time" column, first cell 4320 , second cell 8640 (times in minutes)).
my problem type , type b both being assigned first value in "reminder time" column (the reminder time column column 8).
function pushtocalendar() { var sheet = spreadsheetapp.getactivesheet(); //define reminder, problem seems lie var reminder = sheet.getrange(2, 8).getvalue(); var lastrow = sheet.getlastrow(); var range = sheet.getrange(2, 1, lastrow, 5); var values = range.getvalues(); var calendar = calendarapp.getcalendarbyid('joncodle9gk4@group.calendar.google.com') var numvalues = 0; (var = 0; < values.length; i++) { if ((values[i][0].length > 0) && (values[i][3].length > 0)) { if (values[i][4] != 'y') { var neweventtitle = 'note due: ' + values[i][0] + ' - ' + values[i][3]; var newevent = calendar.createalldayevent(neweventtitle, values[i][2]); newevent.addemailreminder(reminder); var neweventid = newevent.getid(); sheet.getrange(i + 2, 5).setvalue('y'); sheet.getrange(i + 2, 6).setvalue(neweventid); } } numvalues++; } }
your "reminder" ever read h2, rather row event. need move
var reminder = sheet.getrange(2,8).getvalue();
into row loop:
var reminder = sheet.getrange(i+1,8).getvalue();
Comments
Post a Comment