This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
google-form-to-calendar-sync [2018/01/26 01:23] ktiamzon |
google-form-to-calendar-sync [2020/06/13 15:10] (current) |
||
---|---|---|---|
Line 4: | Line 4: | ||
Create a form with these questions: | Create a form with these questions: | ||
+ | * Event Title | ||
+ | * Event Start Date and Time | ||
+ | * Event End Date and Time | ||
+ | * Event Location | ||
+ | * Event Description | ||
+ | * Add Guest | ||
- | Event Title | ||
- | |||
- | Event Start Date and Time | ||
- | |||
- | Event End Date and Time | ||
- | |||
- | Event Location | ||
- | |||
- | Event Description | ||
- | |||
- | Add Guest | ||
Once done, go to Responses then click "View responses in sheets" | Once done, go to Responses then click "View responses in sheets" | ||
Line 30: | Line 25: | ||
Type this code. | Type this code. | ||
- | ====== | + | ===== Code ===== |
- | var moment = Moment.load(); | + | |
+ | var moment = Moment.load(); | ||
var GLOBAL = { | var GLOBAL = { | ||
//the id of the form we will use to create calendar events | //the id of the form we will use to create calendar events | ||
formId : " | formId : " | ||
- | | ||
//the id of the calendar we will create events on | //the id of the calendar we will create events on | ||
calendarId : " | calendarId : " | ||
- | | ||
//a mapping of form item titles to sections of the calendar event | //a mapping of form item titles to sections of the calendar event | ||
formMap : { | formMap : { | ||
Line 51: | Line 44: | ||
}, | }, | ||
} | } | ||
- | |||
function onFormSubmit() { | function onFormSubmit() { | ||
var eventObject = getFormResponse(); | var eventObject = getFormResponse(); | ||
var event = createCalendarEvent(eventObject); | var event = createCalendarEvent(eventObject); | ||
} | } | ||
- | |||
function getFormResponse() { | function getFormResponse() { | ||
// Get a form object by opening the form using the | // Get a form object by opening the form using the | ||
Line 112: | Line 103: | ||
return eventObject; | return eventObject; | ||
} | } | ||
- | |||
| | ||
//Get a calendar object by opening the calendar using the | //Get a calendar object by opening the calendar using the | ||
Line 134: | Line 124: | ||
//end time, and description and guests stored in an | //end time, and description and guests stored in an | ||
//options argument | //options argument | ||
- | var event = calendar.createEvent(title, | + | var event = calendar.createEvent(title, |
- | endTime, options) | + | |
} catch (e) { | } catch (e) { | ||
//delete the guest property from the options variable, | //delete the guest property from the options variable, | ||
Line 142: | Line 131: | ||
delete options.guests | delete options.guests | ||
//create the event without including the guest | //create the event without including the guest | ||
- | var event = calendar.createEvent(title, | + | var event = calendar.createEvent(title, |
- | endTime, options) | + | |
} | } | ||
return event; | return event; |