davepar / gcalendarsync

Apps Script for syncing a Google Spreadsheet with Google Calendar
MIT License
161 stars 46 forks source link

Automatically run when new event added #27

Closed nickwellman closed 6 years ago

nickwellman commented 7 years ago

Dave,

Thanks for providing this script! I am very new to programming, but really looking forward to learning. I am using the script on a sheet that is being fed by a form, and I have modified it to work on my spreadsheet by updating the titlerowmap. It works as you designed it, but I would like to get it to run whenever someone uses the form and a new row is populated, or when one of the fields in a row is changed (for example, when the date of the event changes, the script automatically updates the event on the calendar with the new date.) I have been researching and it looks like the simple trigger onEdit will do this, but I don't understand this trigger yet. Do you think this will work with your script? I look forward to hearing what you have to say.

scottiesev commented 6 years ago

This is something I would also love to do. Have the Update to Calendar button automatically trigger based on a new or changed row in the spread sheet.

scottiesev commented 6 years ago

Looks like it worked to just add a trigger in the script. no actual programming needed :)

davepar commented 6 years ago

That's great. I'll add an example of that to the script. Here's a link to the docs for onEdit: https://developers.google.com/apps-script/guides/triggers/events

davepar commented 6 years ago

I wrote a couple of functions and added some documentation to make it easy to add and delete the trigger. I thought it was going to be an easy matter of adding an "onEdit" function, but the simple triggers aren't allowed to modify the calendar.