I am creating a script that takes information from a form and writes it to a calendar. When I run the script in the script editor it works great, takes information from the spreadsheet and creates a calendar event. However, when I fill out the forma and submit ( submit is the trigger) I get a error stating I do not have permission to call getActiveForm(). I own both form and calendar. I appreciate any ideas.
Code
function createEvent() {
var calendarToUse = "testing";
var ssUrlToUse ='https://docs.google.com/a/bay.k12.fl.us/spreadsheets
/d/1ZTDQL9G5U7RqbbKQbAfb3ERqFwpSsC3EOQxdD1zdQwA/edit#gid=441997215';
/* Get Canalnder*/
var calen = CalendarApp.getCalendarsByName(calendarToUse);
var cal = calen[0];
Logger.log(cal.getName());
/* get info from responses*/
var mySS
=SpreadsheetApp.openByUrl(ssUrlToUse).getActiveSheet()
Logger.log(mySS.getName());
var values = mySS.getDataRange().getValues();
var response = values[values.length-1];
var i=2;
var desc = response[i];
var loc = response[i+1];
var start = makeGreatDate( response[i+2], response[i+4]);
var end = makeGreatDate(response[i+3],response[i+6]);
var title = response[i+5];
/* populate calendar event*/
var event = cal.createEvent(title, start, end, {
description : desc,
location : loc
});
};
function makeGreatDate(date, time) {
var day = new Date(date);
day.setHours(time.getHours());
day.setMinutes(time.getMinutes());
Logger.log( "The Date is"+ day);
return day;
}