Exception: The parameters (String,String,(class)) don't match the method signature for CalendarApp.Calendar.createAllDayEvent.

3,247 views
Skip to first unread message

Amietee Fuondjing

unread,
Jul 11, 2022, 5:15:29 PM7/11/22
to Google Apps Script Community
Can someone tell me what is wrong? I keep getting that exception.


function scheduleEvent()
{
// Open the event calendar
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendarId = spreadsheet.getRange("A2").getValue();
var eventCal = CalendarApp.getCalendarById(calendarId);

// Pull each event into code
var events = spreadsheet.getDataRange().getValues();

// Fill in event details by column
for (x=3; x<events.length; x++)
{
var col = events[x];
var eventName = col[0];
var startDate = col[1];
var endDate = col[2];
var loca = col[3];
var descr = col[4];

if (startDate.valueOf() == endDate.valueOf())
{
eventCal.createAllDayEvent(eventName, startDate, {location: loca, description: descr});
}
else
{
eventCal.createAllDayEvent(eventName, startDate, endDate, {location: loca, description: descr});
}
}
}

Message has been deleted

dimud...@gmail.com

unread,
Jul 11, 2022, 5:47:51 PM7/11/22
to Google Apps Script Community

Amietee Fuondjing

unread,
Jul 11, 2022, 6:14:14 PM7/11/22
to Google Apps Script Community
Do you mind explaining how there are strings? When I pull the data from the spreadsheet the date columns (col[1], col[2]) are in the date format.

Florin Ciobanu

unread,
Sep 11, 2023, 6:26:30 AM9/11/23
to Google Apps Script Community
Use  eventCal.createEvent(eventName, new Date(startTime), new Date (endTime)) to convert string to date
Reply all
Reply to author
Forward
0 new messages