Here is my conversation with chat about building a calendar/form/sheet system
Quite interesting to follow the thread of this script to see how together, chat and I came to a fully working version that I wanted.
Neither of these original responses worked to add the data to my calendar
Add some console.log items to the script to help trouble shoot
function onFormSubmit(e) {
const formData = e.namedValues;
const name = formData['Name'][0];
const description = formData['Description'][0];
const startDateTime = new Date(formData['StartDate'][0]);//i had to fix this
const endDateTime = new Date(formData['EndDate'][0]);//I had to fix this
console.log(name)
console.log(description)
console.log(startDateTime)
console.log(endDateTime)
const calendarId = 'YOUR CAL_ID HERE'; // Replace with your calendar ID
const calendar = CalendarApp.getCalendarById(calendarId);
const event = calendar.createEvent(name, startDateTime, endDateTime, { description: description });
Logger.log("Event created with ID: " + event.getId());
}
/**This script will connect a form to a slide presentation.
* There are some changes you need to make to this script to get it to work with your slide deck.
* This script is attached to the form
* The Question and Response fields need to be added to the slide as text boxes and have those words
* (or other words ) that will be replaced with the contents of the form responses
* Timothy Welch
*/
function audienceResponse(e) {
const slideDeckURL = 'https://docs.google.com/presentation/d/1_FELrNGM58YYZZRWadrnuPxpx_k89KQBzH94Ygx1Wr0/edit#slide=id.g26d2005f8f1_0_16';//replace with your slide deck URL
const openPresentation = SlidesApp.openByUrl(slideDeckURL);
//replace audienceSlide with the slideID you want to duplicate
const audienceSlide = openPresentation.getSlideById('g26d2005f8f1_0_16');//replace with your slide ID
const newSlide = audienceSlide.duplicate();
const newSlideId = newSlide.getObjectId();
var items = e.response.getItemResponses();
const changeSlide = openPresentation.getSlideById(newSlideId);
changeSlide.replaceAllText('Question', items[0].getResponse());//the script will change the word question with the form response in the first form item
changeSlide.replaceAllText('Response', items[1].getResponse());//the script will change the word response with the form response in the second form item
}