Calculate the age of a person and write it to the event's description in your birthday calendar using Google Apps Script
This script uses Google Apps Script to access one's Google Calendar and calculate the age on a person's birthday. In the best case you have a custom calendar where your birthdays are stored at. If not, uncomment line 20 and use the filter function at the bottom.
- Head to https://script.google.com/home/my and create a new project. Rename the existing file Code.gs to your liking and paste the code from calculateAge.gs.
- Paste your calendar ID in line 9 (you can find it in the Google Calendar Settings)
- Make sure to add the birth year of a person to the location field (or customize the script)
- Customize the message in line 36
- Hit run and see the messages appear in your calendar events for the current year!
- Create a trigger to run this every year to calculate the correct age
For some reason I can't recall right now, I really wanted the all day event notification to be the one set as the default so the addPopupReminder command wasn't a solution for me. Thank you for the suggestion tho!
Making use of the Logger is indeed very helpful. I also used it to debug the script one by one! I ended up setting a default all day reminder to 0 days before at 00:00 and deleted and added all the events and ran the script. This way the reminder isn't deleted by the script and goes off at midnight. Good enough :)