hk21702 / YA-GCal-Notion-Sync-Script

Script to synchronize between a Notion database and Google Calendar both ways. Uses Google App Script.
GNU General Public License v3.0
139 stars 10 forks source link

Use different tag as event name #14

Closed jobhasnofriends closed 2 years ago

jobhasnofriends commented 2 years ago

Hi, I'm using Notion as a calendar but because I'm a student I prefer to use the select tag as the identifier for my assignments. I don't use the default name tag at all so whenever I sync my database with my calendar the events say "untitled". Can I somehow change the code so that my select tag shows up as the name in Google calendar? image

hk21702 commented 2 years ago

Using tags as your event name on the GCal side unfortunately would require some non-trivial changes due to how tags function. I won't be adding this functionality since it seems super niche and I'd imagine most people would want to use the actual database title field as the event name on GCal. I can offer some advice as to how to modify the code if you're familiar with coding.

Tags in notion are effectively returned as an array of individual tags that are present for that property. The individual elements has properties like the name and color included. As such, you'll likely want to iterate through all the present tags for the property and concat them into a single string to send as the title to GCal. This just replaces the string that the original title string would have done.

Going in the other direction is much more messy, as there is no real way of distinguishing individual tags from that concat string that we generated before. You could add some special characters you're unlikely to normally use between strings in the original process and then have the code split it back up using the character when going back to Notion, but this character will show up in the title of GCal, and will also mean you'll have to be careful when modifying events from the GCal side. Otherwise, you just add the title string in as a new tag. If there is a tag with a matching string, Notion should just use that, and will otherwise create the new tag. There is an example of this tag adding process with the Notion API that already exists in the code if you look for it. Specifically, the convertToNotionProperty function.