javascript - Google Calendar createAllDayEvent from Google Form Submission -


i'm trying create all-day google calendar event google calendar form submission.

i've managed source below code internet , have modified calendar id , column id's cannot work out how modify create all-day event opposed start/finish event.

i know need modify line createevent(calendarid,title,startdt,enddt,desc) along lines of createalldayevent(title, date) i'm unsure else needs changing.

any appreciated.

//this id of calendar add event to, found on calendar settings page of calendar in question //look "calendar address:" , id shows beside it. var calendarid = "calendar_id_goes_here";  //below column ids of represents values used in spreadsheet (these non 0 indexed)  //column containg start date/time event var startdtid = 4; //column containg end date/time event var enddtid = 5; //column containg first part of title event (in case, name) var titleid = 2; //column containg second part of title event (in case, absence type) var titleid2 = 3; //column containg comments event var descid = 7; //column containg time stamp event (this 1) var formtimestampid = 1;  function getlatestandsubmittocalendar() { //allow access spreadsheet   var sheet = spreadsheetapp.getactivesheet();   var rows = sheet.getdatarange();   var numrows = rows.getnumrows();   var values = rows.getvalues();   var lr = rows.getlastrow(); //removed setting of hour , minute start , end times these set our form   var startdt = sheet.getrange(lr,startdtid,1,1).getvalue();   var enddt = sheet.getrange(lr,enddtid,1,1).getvalue(); //create addition description included added , when   var subon = "added :"+sheet.getrange(lr,formtimestampid,1,1).getvalue()+" by: "+sheet.getrange(lr,titleid,1,1).getvalue(); //setting comments description, , addining in time stamp , submision info   var desc = "comments :"+sheet.getrange(lr,descid,1,1).getvalue()+"\n"+subon; //create title using name , ttype of absence   var title = sheet.getrange(lr,titleid,1,1).getvalue()+" - "+sheet.getrange(lr,titleid2,1,1).getvalue(); //run crete event function     createevent(calendarid,title,startdt,enddt,desc); };  function createevent(calendarid,title,startdt,enddt,desc) {   var cal = calendarapp.getcalendarbyid(calendarid);   var start = new date(startdt);   var end = new date(enddt); //manually set location, can modified dynamic modifying code if need   var loc = 'computer centre';  //set options, in case using description , location, not need guests or sendinvites   var event = cal.createevent(title, start, end, {       description : desc,       location : loc   }); }; 

edit: below attempt @ modifying code accept all-day events. i'm not sure if correct.

//this id of calendar add event to, found on calendar settings page of calendar in question //look "calendar address:" , id shows beside it. var calendarid = "itgeekgroup.com_eakl8j0m8vv2j2cv7jjteq0jd4@group.calendar.google.com";  //below column ids of represents values used in spreadsheet (these non 0 indexed)  //column containg start date/time event var startdtid = 4; //column containg first part of title event (in case, name) var titleid = 2; //column containg second part of title event (in case, absence type) var titleid2 = 3; //column containg comments event var descid = 5; //column containg time stamp event (this 1) var formtimestampid = 1;  function getlatestandsubmittocalendar() { //allow access spreadsheet   var sheet = spreadsheetapp.getactivesheet();   var rows = sheet.getdatarange();   var numrows = rows.getnumrows();   var values = rows.getvalues();   var lr = rows.getlastrow(); //create addition description included added , when   var subon = "added :"+sheet.getrange(lr,formtimestampid,1,1).getvalue()+" by: "+sheet.getrange(lr,titleid,1,1).getvalue(); //setting comments description, , addining in time stamp , submision info   var desc = "comments :"+sheet.getrange(lr,descid,1,1).getvalue()+"\n"+subon; //create title using name , ttype of absence   var title = sheet.getrange(lr,titleid,1,1).getvalue()+" - "+sheet.getrange(lr,titleid2,1,1).getvalue(); //run crete event function     createalldayevent(calendarid,title,startdt,desc); };  function createalldayevent(calendarid,title,startdt,desc) {   var cal = calendarapp.getcalendarbyid(calendarid);   var start = new date(startdt); //manually set location, can modified dynamic modifying code if need   var loc = 'computer centre';  //set options, in case using description , location, not need guests or sendinvites   var event = cal.createevent(title, start, end, {       description : desc,       location : loc   }); }; 

you need use whole method.

you call on line 32 without reference parent methods: createalldayevent(calendarid,title,startdt,desc);

add, @ bottom, calendarapp , getcalendarbyid(id) call createalldayevent

calendarapp.getcalendarbyid("itgeekgroup.com_eakl8j0m8vv2j2cv7jjteq0jd4@group.calendar.google.com").createalldayevent(title,date);


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -