Simple All Day Event - Import Sheet to Cal

28 views
Skip to first unread message

Miwa Mack

unread,
May 24, 2022, 8:55:10 AM5/24/22
to Google Apps Script Community
Hello kind people. 

I've got a very simple sheet with three Col

A = Start Date
B = End Date 
C = Event Description 

I would like to have the ability to import the data from google sheet to a shared google Calendar. 

On each import to DELETE all current calendar events and then write again based on data in cols A, B & C. This would be needed, I think, to prevent endless duplicate evens.

Does anyone have any knowledge of an import all day event from sheet to cal ? 

Keep happy and healthy 
Bliss & Joy 

Todd Miwa Mack 

Adam Geisen

unread,
May 25, 2022, 10:03:14 AM5/25/22
to Google Apps Script Community
I have some sample scripts that might help you get started. At the bottom of this first page is a script that will get the data in a Sheet and loop through it.


In the loop, you can use these scripts to create the event.


If you need more info, let me know and I can help.

Adam

Laurie Nason

unread,
May 26, 2022, 2:14:22 AM5/26/22
to google-apps-sc...@googlegroups.com
On top of Adam's great scripts - I would also add in the following if your calendar could be one that the user will add to with their own stuff - Add in a "tag" to the event, so that when you are running through and deleting the previously automatically created events - check for the key and remove only those events.
The google function is setTag

newEvent.setTag(myKey, 'myValue-Doesn't matter what as we only check for existence of tag, not its content');

There's a bit on filtering by using the tag here - but as Tanaike points out in the comments, it uses a lot of process to do it. In my code to do this, I just grab all the events between today's date (don't care about past ones) and a specified date in the future, and check for the tag before deleting only those ones.

if (allEvents[e].getTag(myKey)!==null){

Hope this helps.
Laurie

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/3b58f6f3-6089-47a6-88ee-d731d9e79c77n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages