I think could be a simple one to solve, I am stuck working this simple issue out.
I have called a createEvent function to create a google calendar event. As part of this function I also get the google calendar event ID as EventId and want to return it.
For some reason I dont quite understand, the EventId value will not return.
var EventId;
createEvent(calendarId,title,startDt,endDt,desc,EventId);
Logger.log('id after func = '+EventId);
sheet.getRange(lr,EventIdHolder,1,1).setValue(EventId);
};
function createEvent(calendarId,title,startDt,endDt,desc,EventId) {
var cal = CalendarApp.getCalendarById(calendarId);
var start = new Date(startDt);
var end = new Date(endDt);
//Manually set the Location, this can be modified to be dynamic by modifying the code if need be
//var loc = sheet.getRange(lr,destId,1,1).getValue();
var loc = "Some Location"
//Set the Options, in this case we are only using Description and Location, as we do not need Guests or sendInvites
var event = cal.createEvent(title, start, end, {
description : desc,
location : loc
});
Logger.log('event = '+event);
var EventId = event.getId();
Logger.log('id generated = '+EventId);
return EventId;
};